# HG changeset patch # User William Morgan # Date 1406494185 25200 # Node ID 57a4bddadd4625b82dfdf414cf2b4234c649c9e6 # Parent 8b6f6e2cbf38d394eb7a8c19cb36513933e7d7da added new helper functions to grids. more bugfixes to gameState.lm which compiles. diff -r 8b6f6e2cbf38 -r 57a4bddadd46 code/dotScanner.lm --- a/code/dotScanner.lm Sun Jul 27 02:35:24 2014 -0700 +++ b/code/dotScanner.lm Sun Jul 27 13:49:45 2014 -0700 @@ -25,6 +25,9 @@ grid:get grid:update:with grid:set:to + gridMaxX + gridMaxY + gridArea grid:inBounds? calcPos ] from: (module: "grid.lm") diff -r 8b6f6e2cbf38 -r 57a4bddadd46 code/gameState.lm --- a/code/gameState.lm Sun Jul 27 02:35:24 2014 -0700 +++ b/code/gameState.lm Sun Jul 27 13:49:45 2014 -0700 @@ -25,6 +25,9 @@ grid:get grid:update:with grid:set:to + gridMaxX + gridMaxY + gridArea grid:inBounds? calcPos ] from: (module: "grid.lm") @@ -34,7 +37,7 @@ (a + b) = 2 } - makeTicker <- :mapWidth mapHeight { + makeTicker <- :mapGrid { lives <- 3 lambdamanPos <- #[5 5] win <- 0 @@ -49,26 +52,25 @@ } } - endOfLives <- makeEventType: (127 * mapWidth * mapHeight * 160) 0 :tick gameState { + endOfLives <- makeEventType: (127 * (mapGrid gridArea) * 16) 0 :tick gameState { lives <- 0 777 print addEvents <- [] #[addEvents gameState] } - - isFood <- :tile {(2 <= tile) and (tile <= 4)} - getLambdaManChoice <- :{0} + isFood <- :tile { (2 <= tile) myAnd: (tile <= 4) } + getLambdaManChoice <- {0} moveLambdaMan <- makeEventType: 127 1 :tick gameState { move <- getLambdaManChoice: newPos <- (calcPos: move lambdamanPos) - impending <- grid: grid get: newPos + impending <- grid: mapGrid get: newPos if: (not: (impending = 0)) { lambdamanPos <- impending - } else { } + } else: { } if: (impending isFood) { #[(moveLambdaMan: (tick + 10)) gameState] - } else { + } else: { #[(moveLambdaMan: tick) gameState] } } @@ -169,7 +171,7 @@ ] print: 6 gameState <- #[0 0] - while: {(tick < runUntil) and (not: (events empty?))} do: { + while: {(tick < runUntil) myAnd: (not: (events empty?))} do: { print: 7 tick <- events nextTick print: 5 @@ -183,7 +185,11 @@ step <- :myState world { print: 1 - ticker <- makeTicker: 10 10 + grid <- makeTree: (map: (world value) :row { + makeTree: row + }) + + ticker <- makeTicker: grid print: 2 ticker: 1000 print: 3 diff -r 8b6f6e2cbf38 -r 57a4bddadd46 code/grid.lm --- a/code/grid.lm Sun Jul 27 02:35:24 2014 -0700 +++ b/code/grid.lm Sun Jul 27 13:49:45 2014 -0700 @@ -39,11 +39,15 @@ grid: grid update: pos with: :el { val } } + gridMaxY <- :grid {grid value} + gridMaxX <- :grid {(get: 0 fromTree: grid) value} + gridArea <- :grid {(grid gridMaxX) * (grid gridMaxY)} + grid:inBounds? <- :grid :pos { x <- pos value y <- pos tail - maxY <- grid value - maxX <- (get: 0 fromTree: grid) value + maxY <- (grid gridMaxY) + maxX <- (grid gridMaxX) ((x >= 0) + (y >= 0) + (x < maxX) + (y < maxY)) > 0 }