annotate code/dotScanner.lm @ 28:75c97fb80602

Tag team simple AI WIP
author William Morgan <billjunk@mrgn.org>
date Sat, 26 Jul 2014 00:03:41 -0700
parents 4f7a421e77c6
children 5d1ac440b9db
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
75c97fb80602 Tag team simple AI WIP
William Morgan <billjunk@mrgn.org>
parents: 26
diff changeset
58
75c97fb80602 Tag team simple AI WIP
William Morgan <billjunk@mrgn.org>
parents: 26
diff changeset
59 flatten <- :lst {
75c97fb80602 Tag team simple AI WIP
William Morgan <billjunk@mrgn.org>
parents: 26
diff changeset
60 fold: lst [] with: :acc el {
75c97fb80602 Tag team simple AI WIP
William Morgan <billjunk@mrgn.org>
parents: 26
diff changeset
61 fold: el acc with: :iacc iel {
75c97fb80602 Tag team simple AI WIP
William Morgan <billjunk@mrgn.org>
parents: 26
diff changeset
62 iel | iacc
75c97fb80602 Tag team simple AI WIP
William Morgan <billjunk@mrgn.org>
parents: 26
diff changeset
63 }
75c97fb80602 Tag team simple AI WIP
William Morgan <billjunk@mrgn.org>
parents: 26
diff changeset
64 }
75c97fb80602 Tag team simple AI WIP
William Morgan <billjunk@mrgn.org>
parents: 26
diff changeset
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 {
28
75c97fb80602 Tag team simple AI WIP
William Morgan <billjunk@mrgn.org>
parents: 26
diff changeset
176 print: #[15 pos]
26
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
177 x <- pos value
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
178 y <- pos tail
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
179 get: x fromTree: (get: y fromTree: grid)
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
180 }
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
181
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 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
183 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
184 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
185 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
186 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
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
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
190 grid:set:to <- :grid :pos :val {
26
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
191 grid: grid update: pos with: :el { val }
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
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
194 grid:inBounds? <- :grid :pos {
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
195 x <- pos value
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
196 y <- pos tail
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
197 maxY <- grid value
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
198 maxX <- (get: 0 fromTree: grid) value
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
199 ((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
200 }
24
37158acf31e5 Initial pass at scan loop
William Morgan <billjunk@mrgn.org>
parents: 12
diff changeset
201
26
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
202 visited <- 0
28
75c97fb80602 Tag team simple AI WIP
William Morgan <billjunk@mrgn.org>
parents: 26
diff changeset
203
75c97fb80602 Tag team simple AI WIP
William Morgan <billjunk@mrgn.org>
parents: 26
diff changeset
204 advancer <- :continuations {
75c97fb80602 Tag team simple AI WIP
William Morgan <billjunk@mrgn.org>
parents: 26
diff changeset
205 print: 5
24
37158acf31e5 Initial pass at scan loop
William Morgan <billjunk@mrgn.org>
parents: 12
diff changeset
206 notdone <- 1
37158acf31e5 Initial pass at scan loop
William Morgan <billjunk@mrgn.org>
parents: 12
diff changeset
207 while: { notdone } do: {
28
75c97fb80602 Tag team simple AI WIP
William Morgan <billjunk@mrgn.org>
parents: 26
diff changeset
208 if: (continuations isInteger?) {
75c97fb80602 Tag team simple AI WIP
William Morgan <billjunk@mrgn.org>
parents: 26
diff changeset
209 notdone <- 0
75c97fb80602 Tag team simple AI WIP
William Morgan <billjunk@mrgn.org>
parents: 26
diff changeset
210 } else: {
75c97fb80602 Tag team simple AI WIP
William Morgan <billjunk@mrgn.org>
parents: 26
diff changeset
211 print: 6
75c97fb80602 Tag team simple AI WIP
William Morgan <billjunk@mrgn.org>
parents: 26
diff changeset
212 continuations <- flatten: (fold: continuations [] with: :acc el{
75c97fb80602 Tag team simple AI WIP
William Morgan <billjunk@mrgn.org>
parents: 26
diff changeset
213 print: 7
75c97fb80602 Tag team simple AI WIP
William Morgan <billjunk@mrgn.org>
parents: 26
diff changeset
214 ret <- acc
75c97fb80602 Tag team simple AI WIP
William Morgan <billjunk@mrgn.org>
parents: 26
diff changeset
215 if: notdone {
75c97fb80602 Tag team simple AI WIP
William Morgan <billjunk@mrgn.org>
parents: 26
diff changeset
216 ret <- el:
75c97fb80602 Tag team simple AI WIP
William Morgan <billjunk@mrgn.org>
parents: 26
diff changeset
217 if: (ret isInteger?) {
75c97fb80602 Tag team simple AI WIP
William Morgan <billjunk@mrgn.org>
parents: 26
diff changeset
218 } else: {
75c97fb80602 Tag team simple AI WIP
William Morgan <billjunk@mrgn.org>
parents: 26
diff changeset
219 if: (ret value) {
75c97fb80602 Tag team simple AI WIP
William Morgan <billjunk@mrgn.org>
parents: 26
diff changeset
220 notdone <- 0
75c97fb80602 Tag team simple AI WIP
William Morgan <billjunk@mrgn.org>
parents: 26
diff changeset
221 ret <- (ret tail)
75c97fb80602 Tag team simple AI WIP
William Morgan <billjunk@mrgn.org>
parents: 26
diff changeset
222 } else: {
75c97fb80602 Tag team simple AI WIP
William Morgan <billjunk@mrgn.org>
parents: 26
diff changeset
223 ret <- (ret tail) | acc
75c97fb80602 Tag team simple AI WIP
William Morgan <billjunk@mrgn.org>
parents: 26
diff changeset
224 }
75c97fb80602 Tag team simple AI WIP
William Morgan <billjunk@mrgn.org>
parents: 26
diff changeset
225 }
75c97fb80602 Tag team simple AI WIP
William Morgan <billjunk@mrgn.org>
parents: 26
diff changeset
226 } else: {}
75c97fb80602 Tag team simple AI WIP
William Morgan <billjunk@mrgn.org>
parents: 26
diff changeset
227 })
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
75c97fb80602 Tag team simple AI WIP
William Morgan <billjunk@mrgn.org>
parents: 26
diff changeset
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
28
75c97fb80602 Tag team simple AI WIP
William Morgan <billjunk@mrgn.org>
parents: 26
diff changeset
257 print: 9
26
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
258 if: (grid: grid inBounds?: myLoc) {
28
75c97fb80602 Tag team simple AI WIP
William Morgan <billjunk@mrgn.org>
parents: 26
diff changeset
259 print: 10
26
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
260 if: (grid: visited get: myLoc) {
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
261 } else: {
28
75c97fb80602 Tag team simple AI WIP
William Morgan <billjunk@mrgn.org>
parents: 26
diff changeset
262 print: 11
26
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
263 atpos <- grid: grid get: myLoc
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
264 if: (atpos = 2) + (atpos = 3) + (atpos = 4) {
28
75c97fb80602 Tag team simple AI WIP
William Morgan <billjunk@mrgn.org>
parents: 26
diff changeset
265 print: 12
26
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
266 ret <- #[1 (reverse: path)]
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
267 } else: {
28
75c97fb80602 Tag team simple AI WIP
William Morgan <billjunk@mrgn.org>
parents: 26
diff changeset
268 print: 13
26
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
269 visited <- grid: visited set: myLoc to: 1
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
270 if: atpos {
28
75c97fb80602 Tag team simple AI WIP
William Morgan <billjunk@mrgn.org>
parents: 26
diff changeset
271 print: 14
26
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
272 move <- 0
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
273 while: { move < 4 } do: {
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
274 ret <- (makeContClos: grid (calcPos: move myLoc) move | path) | ret
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
275 }
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
276 ret <- #[0 ret]
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
277 } else: {}
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
278 }
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
279 }
28
75c97fb80602 Tag team simple AI WIP
William Morgan <billjunk@mrgn.org>
parents: 26
diff changeset
280 } else: {
75c97fb80602 Tag team simple AI WIP
William Morgan <billjunk@mrgn.org>
parents: 26
diff changeset
281 print: 42
75c97fb80602 Tag team simple AI WIP
William Morgan <billjunk@mrgn.org>
parents: 26
diff changeset
282 }
26
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
283 ret
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
284 }
24
37158acf31e5 Initial pass at scan loop
William Morgan <billjunk@mrgn.org>
parents: 12
diff changeset
285 }
37158acf31e5 Initial pass at scan loop
William Morgan <billjunk@mrgn.org>
parents: 12
diff changeset
286
12
1c6d4f2642d0 Fist progress toward a simple recursive dot scanner bot
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
287 step <- :myState world {
28
75c97fb80602 Tag team simple AI WIP
William Morgan <billjunk@mrgn.org>
parents: 26
diff changeset
288 print: -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
289 grid <- makeTree: (map: (world value) :row { makeTree: row })
28
75c97fb80602 Tag team simple AI WIP
William Morgan <billjunk@mrgn.org>
parents: 26
diff changeset
290 print: 0
75c97fb80602 Tag team simple AI WIP
William Morgan <billjunk@mrgn.org>
parents: 26
diff changeset
291 lmState <- (world tail) value
75c97fb80602 Tag team simple AI WIP
William Morgan <billjunk@mrgn.org>
parents: 26
diff changeset
292 print: 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
293 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
294
28
75c97fb80602 Tag team simple AI WIP
William Morgan <billjunk@mrgn.org>
parents: 26
diff changeset
295 print: 2
75c97fb80602 Tag team simple AI WIP
William Morgan <billjunk@mrgn.org>
parents: 26
diff changeset
296 visited <- treeMap: grid :row {
75c97fb80602 Tag team simple AI WIP
William Morgan <billjunk@mrgn.org>
parents: 26
diff changeset
297 treeMap: row :el { 0 }
75c97fb80602 Tag team simple AI WIP
William Morgan <billjunk@mrgn.org>
parents: 26
diff changeset
298 }
75c97fb80602 Tag team simple AI WIP
William Morgan <billjunk@mrgn.org>
parents: 26
diff changeset
299 print: 3
75c97fb80602 Tag team simple AI WIP
William Morgan <billjunk@mrgn.org>
parents: 26
diff changeset
300 path <- advancer: [(makeContClos: grid myLoc [])]
75c97fb80602 Tag team simple AI WIP
William Morgan <billjunk@mrgn.org>
parents: 26
diff changeset
301 print: #[4 path]
75c97fb80602 Tag team simple AI WIP
William Morgan <billjunk@mrgn.org>
parents: 26
diff changeset
302 #[0 (path value)]
12
1c6d4f2642d0 Fist progress toward a simple recursive dot scanner bot
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
303 }
1c6d4f2642d0 Fist progress toward a simple recursive dot scanner bot
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
304
1c6d4f2642d0 Fist progress toward a simple recursive dot scanner bot
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
305 main <- :initWorld mystery {
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