Mercurial > repos > icfp2014
annotate code/dotScanner.lm @ 30:3287eb6c25fe
Sort of working in the game simulator!!!!!
author | William Morgan <billjunk@mrgn.org> |
---|---|
date | Sat, 26 Jul 2014 00:23:19 -0700 |
parents | 5d1ac440b9db |
children | 3812bf35168d |
rev | line source |
---|---|
12
1c6d4f2642d0
Fist progress toward a simple recursive dot scanner bot
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
1 #{ |
23
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
2 length <- :lst { |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
3 len <- [] |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
4 while: { not: (lst isInteger?)} do: { |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
5 lst <- lst tail |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
6 len <- len + 1 |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
7 } |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
8 len |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
9 } |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
10 |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
11 reverse <- :lst { |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
12 new <- [] |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
13 while: { not: (lst isInteger?)} do: { |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
14 new <- (lst value) | new |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
15 lst <- lst tail |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
16 } |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
17 new |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
18 } |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
19 |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
20 split:at <- :lst :pos { |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
21 first <- [] |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
22 i <- 0 |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
23 while: { i < pos } do: { |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
24 first <- (lst value) | first |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
25 lst <- lst tail |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
26 i <- i + 1 |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
27 } |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
28 #[(reverse: first) lst] |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
29 } |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
30 |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
31 map <- :lst fun { |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
32 new <- [] |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
33 while: { not: (lst isInteger?) } do: { |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
34 new <- (fun: (lst value)) | new |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
35 lst <- lst tail |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
36 } |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
37 reverse: new |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
38 } |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
39 |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
40 fold:with <- :lst acc :fun { |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
41 while: { not: (lst isInteger?) } do: { |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
42 acc <- fun: acc (lst value) |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
43 lst <- lst tail |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
44 } |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
45 acc |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
46 } |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
47 |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
48 filter <- :lst pred { |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
49 new <- [] |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
50 while: { not: (lst isInteger?) } do: { |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
51 if: (pred: (lst value)) { |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
52 new <- (lst value) | new |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
53 } else: {} |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
54 lst <- lst tail |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
55 } |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
56 reverse: new |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
57 } |
28 | 58 |
59 flatten <- :lst { | |
60 fold: lst [] with: :acc el { | |
61 fold: el acc with: :iacc iel { | |
62 iel | iacc | |
63 } | |
64 } | |
65 } | |
23
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
66 |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
67 makeTree:size <- :lst :size { |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
68 ret <- 0 |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
69 sub <- 0 |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
70 half <- size / 2 |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
71 if: size = 2 { |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
72 ret <- #[(lst value) ((lst tail) value)] |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
73 } else: { |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
74 if: size = 1 { |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
75 ret <- lst |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
76 } else: { |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
77 sub <- split: lst at: half |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
78 ret <- #[ |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
79 (makeTree: (sub value) size: half) |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
80 (makeTree: (sub tail) size: size-half) |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
81 ] |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
82 } |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
83 } |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
84 ret |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
85 } |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
86 |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
87 makeTree <- :lst { |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
88 size <- lst length |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
89 #[size (makeTree: lst size: size)] |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
90 } |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
91 |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
92 get:fromTree:size <- :idx :tree :size { |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
93 ret <- 0 |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
94 half <- size / 2 |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
95 if: size <= 2 { |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
96 if: idx = 0 { |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
97 ret <- tree value |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
98 } else: { |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
99 ret <- tree tail |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
100 } |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
101 } else: { |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
102 if: idx < half { |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
103 ret <- get: idx fromTree: (tree value) size: half |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
104 } else: { |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
105 ret <- get: idx-half fromTree: (tree tail) size: size-half |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
106 } |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
107 } |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
108 ret |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
109 } |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
110 |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
111 get:fromTree <- :idx :tree { |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
112 size <- tree value |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
113 get: idx fromTree: (tree tail) size: size |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
114 } |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
115 |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
116 treeMap:size <- :tree fun :size { |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
117 ret <- 0 |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
118 half <- size / 2 |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
119 if: size = 2 { |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
120 ret <- #[(fun: (tree value)) (fun: (tree tail))] |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
121 } else: { |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
122 if: size = 1 { |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
123 ret <- #[(fun: (tree value)) 0] |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
124 } else: { |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
125 ret <- #[ |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
126 (treeMap: (tree value) fun size: half) |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
127 (treeMap: (tree tail) fun size: size-half) |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
128 ] |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
129 } |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
130 } |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
131 ret |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
132 } |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
133 |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
134 treeMap <- :tree fun { |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
135 #[(tree value) (treeMap: (tree tail) fun size: (tree value))] |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
136 } |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
137 |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
138 tree:size:update:with <- :tree :size :idx :fun { |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
139 ret <- 0 |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
140 half <- size / 2 |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
141 if: size = 2 { |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
142 if: idx = 0 { |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
143 ret <- #[(fun: (tree value)) (tree tail)] |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
144 } else: { |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
145 ret <- #[(tree value) (fun: (tree tail))] |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
146 } |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
147 } else: { |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
148 if: size = 1 { |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
149 ret <- #[(fun: (tree value)) 0] |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
150 } else: { |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
151 if: (idx < half) { |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
152 ret <- #[ |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
153 (tree: (tree value) size: half update: idx with: fun) |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
154 (tree tail) |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
155 ] |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
156 } else: { |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
157 ret <- #[ |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
158 (tree value) |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
159 (tree: (tree tail) size: size-half update: idx-half with: fun) |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
160 ] |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
161 } |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
162 } |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
163 } |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
164 ret |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
165 } |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
166 |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
167 tree:update:with <- :tree :idx :fun { |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
168 #[(tree value) (tree: (tree tail) size: (tree value) update: idx with: fun)] |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
169 } |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
170 |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
171 tree:set:to <- :tree :idx :val { |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
172 tree: tree update: idx with: :el { val } |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
173 } |
26
4f7a421e77c6
Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents:
25
diff
changeset
|
174 |
4f7a421e77c6
Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents:
25
diff
changeset
|
175 grid:get <- :grid :pos { |
4f7a421e77c6
Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents:
25
diff
changeset
|
176 x <- pos value |
4f7a421e77c6
Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents:
25
diff
changeset
|
177 y <- pos tail |
4f7a421e77c6
Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents:
25
diff
changeset
|
178 get: x fromTree: (get: y fromTree: grid) |
4f7a421e77c6
Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents:
25
diff
changeset
|
179 } |
23
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
180 |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
181 grid:update:with <- :grid :pos :fun { |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
182 x <- pos value |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
183 y <- pos tail |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
184 tree: grid update: y with: :row { |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
185 tree: row update: x with: fun |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
186 } |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
187 } |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
188 |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
189 grid:set:to <- :grid :pos :val { |
26
4f7a421e77c6
Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents:
25
diff
changeset
|
190 grid: grid update: pos with: :el { val } |
4f7a421e77c6
Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents:
25
diff
changeset
|
191 } |
4f7a421e77c6
Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents:
25
diff
changeset
|
192 |
4f7a421e77c6
Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents:
25
diff
changeset
|
193 grid:inBounds? <- :grid :pos { |
4f7a421e77c6
Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents:
25
diff
changeset
|
194 x <- pos value |
4f7a421e77c6
Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents:
25
diff
changeset
|
195 y <- pos tail |
4f7a421e77c6
Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents:
25
diff
changeset
|
196 maxY <- grid value |
4f7a421e77c6
Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents:
25
diff
changeset
|
197 maxX <- (get: 0 fromTree: grid) value |
4f7a421e77c6
Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents:
25
diff
changeset
|
198 ((x >= 0) + (y >= 0) + (x < maxX) + (y < maxY)) > 0 |
23
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
199 } |
24
37158acf31e5
Initial pass at scan loop
William Morgan <billjunk@mrgn.org>
parents:
12
diff
changeset
|
200 |
26
4f7a421e77c6
Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents:
25
diff
changeset
|
201 visited <- 0 |
28 | 202 |
203 advancer <- :continuations { | |
24
37158acf31e5
Initial pass at scan loop
William Morgan <billjunk@mrgn.org>
parents:
12
diff
changeset
|
204 notdone <- 1 |
37158acf31e5
Initial pass at scan loop
William Morgan <billjunk@mrgn.org>
parents:
12
diff
changeset
|
205 while: { notdone } do: { |
28 | 206 if: (continuations isInteger?) { |
207 notdone <- 0 | |
208 } else: { | |
29
5d1ac440b9db
Seems to be working in CPU simulator. Need to remove debug crap
William Morgan <billjunk@mrgn.org>
parents:
28
diff
changeset
|
209 continuations <- fold: continuations [] with: :acc el{ |
28 | 210 ret <- acc |
211 if: notdone { | |
212 ret <- el: | |
213 if: (ret isInteger?) { | |
214 } else: { | |
215 if: (ret value) { | |
216 notdone <- 0 | |
217 ret <- (ret tail) | |
218 } else: { | |
219 ret <- (ret tail) | acc | |
220 } | |
221 } | |
222 } else: {} | |
29
5d1ac440b9db
Seems to be working in CPU simulator. Need to remove debug crap
William Morgan <billjunk@mrgn.org>
parents:
28
diff
changeset
|
223 ret |
5d1ac440b9db
Seems to be working in CPU simulator. Need to remove debug crap
William Morgan <billjunk@mrgn.org>
parents:
28
diff
changeset
|
224 } |
5d1ac440b9db
Seems to be working in CPU simulator. Need to remove debug crap
William Morgan <billjunk@mrgn.org>
parents:
28
diff
changeset
|
225 if: notdone { |
5d1ac440b9db
Seems to be working in CPU simulator. Need to remove debug crap
William Morgan <billjunk@mrgn.org>
parents:
28
diff
changeset
|
226 continuations <- flatten: continuations |
5d1ac440b9db
Seems to be working in CPU simulator. Need to remove debug crap
William Morgan <billjunk@mrgn.org>
parents:
28
diff
changeset
|
227 } else: {} |
24
37158acf31e5
Initial pass at scan loop
William Morgan <billjunk@mrgn.org>
parents:
12
diff
changeset
|
228 } |
37158acf31e5
Initial pass at scan loop
William Morgan <billjunk@mrgn.org>
parents:
12
diff
changeset
|
229 } |
28 | 230 continuations |
26
4f7a421e77c6
Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents:
25
diff
changeset
|
231 } |
4f7a421e77c6
Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents:
25
diff
changeset
|
232 |
4f7a421e77c6
Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents:
25
diff
changeset
|
233 calcPos <- :move from { |
4f7a421e77c6
Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents:
25
diff
changeset
|
234 x <- from value |
4f7a421e77c6
Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents:
25
diff
changeset
|
235 y <- from tail |
4f7a421e77c6
Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents:
25
diff
changeset
|
236 if: move { |
4f7a421e77c6
Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents:
25
diff
changeset
|
237 if: move = 1 { |
4f7a421e77c6
Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents:
25
diff
changeset
|
238 x <- x + 1 |
4f7a421e77c6
Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents:
25
diff
changeset
|
239 } else: { |
4f7a421e77c6
Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents:
25
diff
changeset
|
240 if: move = 2 { |
4f7a421e77c6
Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents:
25
diff
changeset
|
241 y <- y + 1 |
4f7a421e77c6
Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents:
25
diff
changeset
|
242 } else: { |
4f7a421e77c6
Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents:
25
diff
changeset
|
243 x <- x - 1 |
4f7a421e77c6
Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents:
25
diff
changeset
|
244 } |
4f7a421e77c6
Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents:
25
diff
changeset
|
245 } |
4f7a421e77c6
Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents:
25
diff
changeset
|
246 } else: { |
4f7a421e77c6
Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents:
25
diff
changeset
|
247 y <- y - 1 |
4f7a421e77c6
Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents:
25
diff
changeset
|
248 } |
4f7a421e77c6
Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents:
25
diff
changeset
|
249 #[x y] |
24
37158acf31e5
Initial pass at scan loop
William Morgan <billjunk@mrgn.org>
parents:
12
diff
changeset
|
250 } |
26
4f7a421e77c6
Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents:
25
diff
changeset
|
251 |
4f7a421e77c6
Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents:
25
diff
changeset
|
252 makeContClos <- :grid myLoc path { |
4f7a421e77c6
Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents:
25
diff
changeset
|
253 { |
4f7a421e77c6
Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents:
25
diff
changeset
|
254 ret <- [] |
4f7a421e77c6
Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents:
25
diff
changeset
|
255 move <- 0 |
4f7a421e77c6
Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents:
25
diff
changeset
|
256 atpos <- 0 |
4f7a421e77c6
Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents:
25
diff
changeset
|
257 if: (grid: grid inBounds?: myLoc) { |
4f7a421e77c6
Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents:
25
diff
changeset
|
258 if: (grid: visited get: myLoc) { |
4f7a421e77c6
Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents:
25
diff
changeset
|
259 } else: { |
4f7a421e77c6
Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents:
25
diff
changeset
|
260 atpos <- grid: grid get: myLoc |
4f7a421e77c6
Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents:
25
diff
changeset
|
261 if: (atpos = 2) + (atpos = 3) + (atpos = 4) { |
4f7a421e77c6
Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents:
25
diff
changeset
|
262 ret <- #[1 (reverse: path)] |
4f7a421e77c6
Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents:
25
diff
changeset
|
263 } else: { |
4f7a421e77c6
Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents:
25
diff
changeset
|
264 visited <- grid: visited set: myLoc to: 1 |
4f7a421e77c6
Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents:
25
diff
changeset
|
265 if: atpos { |
4f7a421e77c6
Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents:
25
diff
changeset
|
266 move <- 0 |
4f7a421e77c6
Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents:
25
diff
changeset
|
267 while: { move < 4 } do: { |
4f7a421e77c6
Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents:
25
diff
changeset
|
268 ret <- (makeContClos: grid (calcPos: move myLoc) move | path) | ret |
29
5d1ac440b9db
Seems to be working in CPU simulator. Need to remove debug crap
William Morgan <billjunk@mrgn.org>
parents:
28
diff
changeset
|
269 move <- move + 1 |
26
4f7a421e77c6
Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents:
25
diff
changeset
|
270 } |
4f7a421e77c6
Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents:
25
diff
changeset
|
271 ret <- #[0 ret] |
4f7a421e77c6
Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents:
25
diff
changeset
|
272 } else: {} |
4f7a421e77c6
Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents:
25
diff
changeset
|
273 } |
4f7a421e77c6
Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents:
25
diff
changeset
|
274 } |
28 | 275 } else: { |
276 } | |
26
4f7a421e77c6
Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents:
25
diff
changeset
|
277 ret |
4f7a421e77c6
Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents:
25
diff
changeset
|
278 } |
24
37158acf31e5
Initial pass at scan loop
William Morgan <billjunk@mrgn.org>
parents:
12
diff
changeset
|
279 } |
37158acf31e5
Initial pass at scan loop
William Morgan <billjunk@mrgn.org>
parents:
12
diff
changeset
|
280 |
12
1c6d4f2642d0
Fist progress toward a simple recursive dot scanner bot
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
281 step <- :myState world { |
23
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
282 grid <- makeTree: (map: (world value) :row { makeTree: row }) |
28 | 283 lmState <- (world tail) value |
23
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
284 myLoc <- (lmState tail) value |
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
285 |
28 | 286 visited <- treeMap: grid :row { |
287 treeMap: row :el { 0 } | |
288 } | |
289 path <- advancer: [(makeContClos: grid myLoc [])] | |
290 #[0 (path value)] | |
12
1c6d4f2642d0
Fist progress toward a simple recursive dot scanner bot
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
291 } |
1c6d4f2642d0
Fist progress toward a simple recursive dot scanner bot
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
292 |
30
3287eb6c25fe
Sort of working in the game simulator!!!!!
William Morgan <billjunk@mrgn.org>
parents:
29
diff
changeset
|
293 main <- :initWorld ghostCode { |
3287eb6c25fe
Sort of working in the game simulator!!!!!
William Morgan <billjunk@mrgn.org>
parents:
29
diff
changeset
|
294 /* |
29
5d1ac440b9db
Seems to be working in CPU simulator. Need to remove debug crap
William Morgan <billjunk@mrgn.org>
parents:
28
diff
changeset
|
295 print: (step: 0 #[ |
5d1ac440b9db
Seems to be working in CPU simulator. Need to remove debug crap
William Morgan <billjunk@mrgn.org>
parents:
28
diff
changeset
|
296 [ |
5d1ac440b9db
Seems to be working in CPU simulator. Need to remove debug crap
William Morgan <billjunk@mrgn.org>
parents:
28
diff
changeset
|
297 [0 0 0 0] |
5d1ac440b9db
Seems to be working in CPU simulator. Need to remove debug crap
William Morgan <billjunk@mrgn.org>
parents:
28
diff
changeset
|
298 [0 2 2 0] |
5d1ac440b9db
Seems to be working in CPU simulator. Need to remove debug crap
William Morgan <billjunk@mrgn.org>
parents:
28
diff
changeset
|
299 [0 1 0 0] |
5d1ac440b9db
Seems to be working in CPU simulator. Need to remove debug crap
William Morgan <billjunk@mrgn.org>
parents:
28
diff
changeset
|
300 [0 0 0 0] |
5d1ac440b9db
Seems to be working in CPU simulator. Need to remove debug crap
William Morgan <billjunk@mrgn.org>
parents:
28
diff
changeset
|
301 ] |
5d1ac440b9db
Seems to be working in CPU simulator. Need to remove debug crap
William Morgan <billjunk@mrgn.org>
parents:
28
diff
changeset
|
302 #[0 #[1 2] 2 3 0] |
5d1ac440b9db
Seems to be working in CPU simulator. Need to remove debug crap
William Morgan <billjunk@mrgn.org>
parents:
28
diff
changeset
|
303 [] |
5d1ac440b9db
Seems to be working in CPU simulator. Need to remove debug crap
William Morgan <billjunk@mrgn.org>
parents:
28
diff
changeset
|
304 0 |
30
3287eb6c25fe
Sort of working in the game simulator!!!!!
William Morgan <billjunk@mrgn.org>
parents:
29
diff
changeset
|
305 ]) */ |
23
5ded24518dc5
Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
306 #[0 step] |
12
1c6d4f2642d0
Fist progress toward a simple recursive dot scanner bot
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
307 } |
1c6d4f2642d0
Fist progress toward a simple recursive dot scanner bot
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
308 } |
1c6d4f2642d0
Fist progress toward a simple recursive dot scanner bot
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
309 |
1c6d4f2642d0
Fist progress toward a simple recursive dot scanner bot
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
310 |