Mercurial > repos > icfp2014
comparison 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 |
comparison
equal
deleted
inserted
replaced
45:75f808e60aa8 | 46:d631e68a45d5 |
---|---|
19 tree:size:update:with | 19 tree:size:update:with |
20 tree:update:with | 20 tree:update:with |
21 tree:set:to | 21 tree:set:to |
22 ] from: (module: "tree.lm") | 22 ] from: (module: "tree.lm") |
23 | 23 |
24 grid:get <- :grid :pos { | 24 import: [ |
25 x <- pos value | 25 grid:get |
26 y <- pos tail | 26 grid:update:with |
27 get: x fromTree: (get: y fromTree: grid) | 27 grid:set:to |
28 } | 28 grid:inBounds? |
29 | 29 calcPos |
30 grid:update:with <- :grid :pos :fun { | 30 ] from: (module: "grid.lm") |
31 x <- pos value | |
32 y <- pos tail | |
33 tree: grid update: y with: :row { | |
34 tree: row update: x with: fun | |
35 } | |
36 } | |
37 | |
38 grid:set:to <- :grid :pos :val { | |
39 grid: grid update: pos with: :el { val } | |
40 } | |
41 | |
42 grid:inBounds? <- :grid :pos { | |
43 x <- pos value | |
44 y <- pos tail | |
45 maxY <- grid value | |
46 maxX <- (get: 0 fromTree: grid) value | |
47 ((x >= 0) + (y >= 0) + (x < maxX) + (y < maxY)) > 0 | |
48 } | |
49 | 31 |
50 visited <- 0 | 32 visited <- 0 |
51 | 33 |
52 advancer <- :continuations { | 34 advancer <- :continuations { |
53 notdone <- 1 | 35 notdone <- 1 |
76 continuations <- flatten: continuations | 58 continuations <- flatten: continuations |
77 } else: {} | 59 } else: {} |
78 } | 60 } |
79 } | 61 } |
80 continuations | 62 continuations |
81 } | |
82 | |
83 calcPos <- :move from { | |
84 x <- from value | |
85 y <- from tail | |
86 if: move { | |
87 if: move = 1 { | |
88 x <- x + 1 | |
89 } else: { | |
90 if: move = 2 { | |
91 y <- y + 1 | |
92 } else: { | |
93 x <- x - 1 | |
94 } | |
95 } | |
96 } else: { | |
97 y <- y - 1 | |
98 } | |
99 #[x y] | |
100 } | 63 } |
101 | 64 |
102 makeContClos <- :grid myLoc path { | 65 makeContClos <- :grid myLoc path { |
103 { | 66 { |
104 ret <- [] | 67 ret <- [] |