changeset 11:f28e465e9ee6

tried to unf*ck, ashamed rebarfing
author William Morgan <bill@mrgn.org>
date Sat, 14 Jul 2012 02:21:32 -0700
parents 370a1eeb8812
children 6ef6dc8ab95e
files src/sim.tp
diffstat 1 files changed, 57 insertions(+), 45 deletions(-) [+]
line wrap: on
line diff
--- a/src/sim.tp	Sat Jul 14 01:58:43 2012 -0700
+++ b/src/sim.tp	Sat Jul 14 02:21:32 2012 -0700
@@ -1,6 +1,4 @@
-#{
-
-	// utilities 
+{
 	true <- #{
 	  if:else <- :self trueblock :elseblock {
 		trueblock:
@@ -13,19 +11,7 @@
 	  }
 	}
 
-	foreach <- :string action {
-		strLen <- string byte_length:
-		index <- 0
-		while: {index < strLen} do {
-			element <- (string byte: index)
-			action: index element
-			index <- index + 1
-		}
-	}
-	// end utilities
-
-
-	cellTypes <- #{
+	makeCellTypes <- {
 		allstr <- #[]
 		allobj <- #[]
 		new <- :idstr {
@@ -37,38 +23,63 @@
 			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
+		#{
+			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
+					}
 				}
-				if: index <- (allstr length) {
-					allobj get: index
-				} else: {
-					empty
+			}
+			wall        <- new: "#"
+			empty       <- new: " "
+			earth       <- new: "."
+			rock        <- new: "*"
+			lambda      <- new: "\\"
+			closedlift  <- new: "L"
+			openlift    <- new: "O"
+			newline     <- new: "\n"
+			robot       <- {
+				#{
+					id <- ("R"  byte: 0) 
+					isrobot <- { true }
+					heldBreath <- 0
 				}
 			}
 		}
-		wall        <- new: "#"
-		empty       <- new: " "
-		earth       <- new: "."
-		rock        <- new: "*"
-		lambda      <- new: "\\"
-		closedlift  <- new: "L"
-		openlift    <- new: "O"
-		newline     <- new: "\n"
-		robot       <- {
-		#{
-			id <- ("R"  byte: 0) 
-			isrobot <- { true }
-			heldBreath <- 0
+    }
+	ttrue <- true
+	tfalse <- false
+#{
+
+	// utilities 
+	true <- {ttrue}
+
+	false <- {tfalse}
+
+	foreach <- :string action {
+		strLen <- string byte_length:
+		index <- 0
+		while: {index < strLen} do: {
+			element <- (string byte: index)
+			action: index element
+			index <- index + 1
 		}
-    }
+	}
+	// end utilities
+
+
+	cellTypes <- makeCellTypes:
 
 	state <- #{
 		new <- :in_grid in_width in_height { 
@@ -102,8 +113,8 @@
 					ended <- roboMove = "A"
 				}
 				doUpdate <- {
-					updateCell <- :x, y {
-						if
+					updateCell <- :x y {
+						//if
 					}
 				}
 				advance <- :roboCmd {
@@ -189,3 +200,4 @@
 	}
 
 }
+}