Mercurial > repos > icfp2014
comparison code/grid.lm @ 50:57a4bddadd46
added new helper functions to grids. more bugfixes to gameState.lm which compiles.
author | William Morgan <billjunk@mrgn.org> |
---|---|
date | Sun, 27 Jul 2014 13:49:45 -0700 |
parents | d631e68a45d5 |
children | d087d0b28039 |
comparison
equal
deleted
inserted
replaced
48:8b6f6e2cbf38 | 50:57a4bddadd46 |
---|---|
37 | 37 |
38 grid:set:to <- :grid :pos :val { | 38 grid:set:to <- :grid :pos :val { |
39 grid: grid update: pos with: :el { val } | 39 grid: grid update: pos with: :el { val } |
40 } | 40 } |
41 | 41 |
42 gridMaxY <- :grid {grid value} | |
43 gridMaxX <- :grid {(get: 0 fromTree: grid) value} | |
44 gridArea <- :grid {(grid gridMaxX) * (grid gridMaxY)} | |
45 | |
42 grid:inBounds? <- :grid :pos { | 46 grid:inBounds? <- :grid :pos { |
43 x <- pos value | 47 x <- pos value |
44 y <- pos tail | 48 y <- pos tail |
45 maxY <- grid value | 49 maxY <- (grid gridMaxY) |
46 maxX <- (get: 0 fromTree: grid) value | 50 maxX <- (grid gridMaxX) |
47 ((x >= 0) + (y >= 0) + (x < maxX) + (y < maxY)) > 0 | 51 ((x >= 0) + (y >= 0) + (x < maxX) + (y < maxY)) > 0 |
48 } | 52 } |
49 | 53 |
50 calcPos <- :move from { | 54 calcPos <- :move from { |
51 x <- from value | 55 x <- from value |