# HG changeset patch # User William Morgan # Date 1342241283 25200 # Node ID 86cdb799f9507b7cb8eba89b2843a146fe86aea5 # Parent be946b2a2cbc813cc7e5afd0865907d22ab7bb2d unbarfed some things diff -r be946b2a2cbc -r 86cdb799f950 src/sim.tp --- a/src/sim.tp Fri Jul 13 21:10:10 2012 -0700 +++ b/src/sim.tp Fri Jul 13 21:48:03 2012 -0700 @@ -11,21 +11,21 @@ } } - cellType <- # { - robot <- "R" byte 0 - wall <- "#" byte 0 - rock <- "*" byte 0 - lambda <- "\" byte 0 - closedlift <- "L" byte 0 - openlift <- "O" byte 0 - earth <- "." byte 0 - empty <- " " byte 0 - newline <- "\n" byte 0 + cellType <- #{ + robot <- ("R" byte: 0) + wall <- ("#" byte: 0) + rock <- ("*" byte: 0) + lambda <- ("\\" byte: 0) + closedlift <- ("L" byte: 0) + openlift <- ("O" byte: 0) + earth <- ("." byte: 0) + empty <- (" " byte: 0) + newline <- ("\n" byte: 0) } state <- #{ - new <- : in_grid in_width in_height { - dst_grid <- #[] + new <- :in_grid in_width in_height { + next_grid <- #[] foreach: in_grid :index el{ dst_grid append: el } @@ -43,11 +43,13 @@ collected <- 0 moves <- 0 ended <- false + doMove <- :roboMove { + ended <- roboMove = "A" + } advance <- :roboMove { - nextState <- deepCopy: self - nextState <- doMove: - nextState ended <- ended: - nextState moves <- moves + 1 + doMove: roboMove + moves <- moves + 1 + self } } @@ -60,7 +62,7 @@ while: {index < strLen} do { curByte <- str byte: index if: curByte = (cellType newline) { - + maxRow <- if: curRow > maxRow {curRow} else: {maxRow} } else: { curRow = curRow + 1 } @@ -89,10 +91,6 @@ } } - ended <- :simState roboMove { - if: roboMove = "A" {} - } - main <- { }