# HG changeset patch # User Mike Pavone # Date 1342255585 25200 # Node ID 66ea6fdd3fcb29539d3d6ec218acb9eea9a14ff1 # Parent 5941e6b3684c1cd6ad2b68bc03b75ed0dcb32de2# Parent 1bd46f854dbbfd035e5745baf7b5f931500722e5 Merge diff -r 5941e6b3684c -r 66ea6fdd3fcb src/sim.tp --- a/src/sim.tp Sat Jul 14 01:42:05 2012 -0700 +++ b/src/sim.tp Sat Jul 14 01:46:25 2012 -0700 @@ -11,16 +11,47 @@ } } - 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) + cellTypes <- #{ + allstr <- #[] + allobj <- #[] + make <- :idstr { + ret <- #{ + id <- (idstr byte: 0) + } + allobj append: ret + allstr append: idstr + ret + } + find <- :idstr { + if: idstr = "R" { robot } else: { + index <- 0 + while: { + if: index < (allstr length) { + (allstr get: index) != idstr + } else: {false} + } do: { + index <- index + 1 + } + if: index <- (allstr length) { + allobj get: index + } else: { + empty + } + } + } + wall <- make: "#" + empty <- make: " " + earth <- make: "." + rock <- make: "*" + lambda <- make: "\\" + closedlift <- make: "L" + openlift <- make: "O" + newline <- make: "\n" + robot <- { + #{ + id <- ("R" byte: 0) + heldBreath <- 0 + } } state <- #{ @@ -33,6 +64,7 @@ grid <- in_grid width <- in_width height <- in_height + robot <- cellTypes robot address <- :x y { x + y * width } setCell <- :x y cell { grid set: (address: x y) cell @@ -40,15 +72,27 @@ getCell <- :x y { grid get: (address: x y) } + water <- 0 + flooding <- 0 + waterproof <- 10 collected <- 0 moves <- 0 ended <- false doMove <- :roboMove { + + robo <- doMove r + nexty <- doMove y ended <- roboMove = "A" } - advance <- :roboMove { - doMove: roboMove + doUpdate <- { + updateCell <- :x, y { + if + } + } + advance <- :roboCmd { + robot move: roboCmd moves <- moves + 1 + doUpdate: self } @@ -61,7 +105,7 @@ curRow <- 0 while: {index < strLen} do: { curByte <- str byte: index - if: curByte = (cellType newline) { + if: curByte = (cellType newline id) { maxRow <- if: curRow > maxRow {curRow} else: {maxRow} } else: { curRow = curRow + 1