diff code/dotScanner.lm @ 46:d631e68a45d5

separated out grid functions for reuse inside gameState.lm
author William Morgan <billjunk@mrgn.org>
date Sun, 27 Jul 2014 01:36:39 -0700
parents d5ccb66ae98b
children 57a4bddadd46
line wrap: on
line diff
--- a/code/dotScanner.lm	Sat Jul 26 23:30:55 2014 -0700
+++ b/code/dotScanner.lm	Sun Jul 27 01:36:39 2014 -0700
@@ -21,31 +21,13 @@
 		tree:set:to
 	] from: (module: "tree.lm")
 
-	grid:get <- :grid :pos {
-		x <- pos value
-		y <- pos tail
-		get: x fromTree: (get: y fromTree: grid)
-	}
-	
-	grid:update:with <- :grid :pos :fun {
-		x <- pos value
-		y <- pos tail
-		tree: grid update: y with: :row {
-			tree: row update: x with: fun
-		}
-	}
-	
-	grid:set:to <- :grid :pos :val {
-		grid: grid update: pos with: :el { val }
-	}
-
-	grid:inBounds? <- :grid :pos {
-		x <- pos value
-		y <- pos tail
-		maxY <- grid value
-		maxX <- (get: 0 fromTree: grid) value
-		((x >= 0) + (y >= 0) + (x < maxX) + (y < maxY)) > 0
-	}
+	import: [
+		grid:get	
+		grid:update:with
+		grid:set:to
+		grid:inBounds?
+		calcPos
+	] from: (module: "grid.lm")
 
 	visited <- 0
 
@@ -80,25 +62,6 @@
 		continuations
 	}
 
-	calcPos <- :move from {
-		x <- from value
-		y <- from tail
-		if: move {
-			if: move = 1 {
-				x <- x + 1
-			} else: {
-				if: move = 2 {
-					y <- y + 1
-				} else: {
-					x <- x - 1
-				}
-			}
-		} else: {
-			y <- y - 1
-		}
-		#[x y]
-	}
-
 	makeContClos <- :grid myLoc path {
 		{
 			ret <- []