# HG changeset patch # User William Morgan # Date 1342260422 25200 # Node ID 6ef6dc8ab95e36e69572f97a2a61a63cf3ee0d33 # Parent f28e465e9ee6f588d72bc44f2c711f4e05727054 Get simulator compiling diff -r f28e465e9ee6 -r 6ef6dc8ab95e src/sim.tp --- a/src/sim.tp Sat Jul 14 02:21:32 2012 -0700 +++ b/src/sim.tp Sat Jul 14 03:07:02 2012 -0700 @@ -11,6 +11,16 @@ } } + eachbyte <- :string action { + strLen <- string byte_length: + index <- 0 + while: {index < strLen} do: { + element <- (string byte: index) + action: index element + index <- index + 1 + } + } + makeCellTypes <- { allstr <- #[] allobj <- #[] @@ -25,7 +35,7 @@ } #{ find <- :idstr { - if: idstr = "R" { robot } else: { + if: idstr = "R" { robot: } else: { index <- 0 while: { if: index < (allstr length) { @@ -63,19 +73,10 @@ #{ // utilities - true <- {ttrue} - - false <- {tfalse} + true <- ttrue - foreach <- :string action { - strLen <- string byte_length: - index <- 0 - while: {index < strLen} do: { - element <- (string byte: index) - action: index element - index <- index + 1 - } - } + false <- tfalse + // end utilities @@ -106,18 +107,11 @@ collected <- 0 moves <- 0 ended <- false - doMove <- :roboMove { - - robo <- doMove r - nexty <- doMove y - ended <- roboMove = "A" - } doUpdate <- { - updateCell <- :x y { - //if - } + true } advance <- :roboCmd { + ended <- roboCmd = "A" robot move: roboCmd moves <- moves + 1 doUpdate: @@ -131,7 +125,7 @@ strLen <- str byte_length: maxRow <- 0 curRow <- 0 - foreach: str :index element { + eachbyte: str :index element { if: element = ((cellTypes newline) id) { maxRow <- if: curRow > maxRow {curRow} else: {maxRow} curRow <- 0 @@ -140,7 +134,7 @@ } } - foreach: str :index element { + eachbyte: str :index element { if: element = ((cellTypes newline) id) { // add spaces curRow <- 0