changeset 6:86cdb799f950

unbarfed some things
author William Morgan <bill@mrgn.org>
date Fri, 13 Jul 2012 21:48:03 -0700
parents be946b2a2cbc
children 1bd46f854dbb 5941e6b3684c
files src/sim.tp
diffstat 1 files changed, 19 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- 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 <- {
 		
 	}