annotate code/dotScanner.lm @ 45:75f808e60aa8

initial simulator ticker. needs print debug cleanup.
author William Morgan <billjunk@mrgn.org>
date Sat, 26 Jul 2014 23:30:55 -0700
parents d5ccb66ae98b
children d631e68a45d5
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 #{
40
d5ccb66ae98b Move some basic library code out of dotScanner.lm into separate files now that import:from works
Michael Pavone <pavone@retrodev.com>
parents: 35
diff changeset
2 import: [
d5ccb66ae98b Move some basic library code out of dotScanner.lm into separate files now that import:from works
Michael Pavone <pavone@retrodev.com>
parents: 35
diff changeset
3 length
d5ccb66ae98b Move some basic library code out of dotScanner.lm into separate files now that import:from works
Michael Pavone <pavone@retrodev.com>
parents: 35
diff changeset
4 reverse
d5ccb66ae98b Move some basic library code out of dotScanner.lm into separate files now that import:from works
Michael Pavone <pavone@retrodev.com>
parents: 35
diff changeset
5 split:at
d5ccb66ae98b Move some basic library code out of dotScanner.lm into separate files now that import:from works
Michael Pavone <pavone@retrodev.com>
parents: 35
diff changeset
6 map
d5ccb66ae98b Move some basic library code out of dotScanner.lm into separate files now that import:from works
Michael Pavone <pavone@retrodev.com>
parents: 35
diff changeset
7 fold:with
d5ccb66ae98b Move some basic library code out of dotScanner.lm into separate files now that import:from works
Michael Pavone <pavone@retrodev.com>
parents: 35
diff changeset
8 filter
d5ccb66ae98b Move some basic library code out of dotScanner.lm into separate files now that import:from works
Michael Pavone <pavone@retrodev.com>
parents: 35
diff changeset
9 flatten
d5ccb66ae98b Move some basic library code out of dotScanner.lm into separate files now that import:from works
Michael Pavone <pavone@retrodev.com>
parents: 35
diff changeset
10 ] from: (module: "ll.lm")
d5ccb66ae98b Move some basic library code out of dotScanner.lm into separate files now that import:from works
Michael Pavone <pavone@retrodev.com>
parents: 35
diff changeset
11
d5ccb66ae98b Move some basic library code out of dotScanner.lm into separate files now that import:from works
Michael Pavone <pavone@retrodev.com>
parents: 35
diff changeset
12 import: [
d5ccb66ae98b Move some basic library code out of dotScanner.lm into separate files now that import:from works
Michael Pavone <pavone@retrodev.com>
parents: 35
diff changeset
13 makeTree:size
d5ccb66ae98b Move some basic library code out of dotScanner.lm into separate files now that import:from works
Michael Pavone <pavone@retrodev.com>
parents: 35
diff changeset
14 makeTree
d5ccb66ae98b Move some basic library code out of dotScanner.lm into separate files now that import:from works
Michael Pavone <pavone@retrodev.com>
parents: 35
diff changeset
15 get:fromTree:size
d5ccb66ae98b Move some basic library code out of dotScanner.lm into separate files now that import:from works
Michael Pavone <pavone@retrodev.com>
parents: 35
diff changeset
16 get:fromTree
d5ccb66ae98b Move some basic library code out of dotScanner.lm into separate files now that import:from works
Michael Pavone <pavone@retrodev.com>
parents: 35
diff changeset
17 treeMap:size
d5ccb66ae98b Move some basic library code out of dotScanner.lm into separate files now that import:from works
Michael Pavone <pavone@retrodev.com>
parents: 35
diff changeset
18 treeMap
d5ccb66ae98b Move some basic library code out of dotScanner.lm into separate files now that import:from works
Michael Pavone <pavone@retrodev.com>
parents: 35
diff changeset
19 tree:size:update:with
d5ccb66ae98b Move some basic library code out of dotScanner.lm into separate files now that import:from works
Michael Pavone <pavone@retrodev.com>
parents: 35
diff changeset
20 tree:update:with
d5ccb66ae98b Move some basic library code out of dotScanner.lm into separate files now that import:from works
Michael Pavone <pavone@retrodev.com>
parents: 35
diff changeset
21 tree:set:to
d5ccb66ae98b Move some basic library code out of dotScanner.lm into separate files now that import:from works
Michael Pavone <pavone@retrodev.com>
parents: 35
diff changeset
22 ] from: (module: "tree.lm")
26
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
23
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
24 grid:get <- :grid :pos {
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
25 x <- pos value
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
26 y <- pos tail
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
27 get: x fromTree: (get: y fromTree: grid)
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
28 }
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
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 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
31 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
32 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
33 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
34 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
35 }
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code 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
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code 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 grid:set:to <- :grid :pos :val {
26
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
39 grid: grid update: pos with: :el { val }
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
40 }
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
41
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
42 grid:inBounds? <- :grid :pos {
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
43 x <- pos value
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
44 y <- pos tail
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
45 maxY <- grid value
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
46 maxX <- (get: 0 fromTree: grid) value
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
47 ((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
48 }
24
37158acf31e5 Initial pass at scan loop
William Morgan <billjunk@mrgn.org>
parents: 12
diff changeset
49
26
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
50 visited <- 0
28
75c97fb80602 Tag team simple AI WIP
William Morgan <billjunk@mrgn.org>
parents: 26
diff changeset
51
75c97fb80602 Tag team simple AI WIP
William Morgan <billjunk@mrgn.org>
parents: 26
diff changeset
52 advancer <- :continuations {
24
37158acf31e5 Initial pass at scan loop
William Morgan <billjunk@mrgn.org>
parents: 12
diff changeset
53 notdone <- 1
37158acf31e5 Initial pass at scan loop
William Morgan <billjunk@mrgn.org>
parents: 12
diff changeset
54 while: { notdone } do: {
28
75c97fb80602 Tag team simple AI WIP
William Morgan <billjunk@mrgn.org>
parents: 26
diff changeset
55 if: (continuations isInteger?) {
75c97fb80602 Tag team simple AI WIP
William Morgan <billjunk@mrgn.org>
parents: 26
diff changeset
56 notdone <- 0
75c97fb80602 Tag team simple AI WIP
William Morgan <billjunk@mrgn.org>
parents: 26
diff changeset
57 } else: {
29
5d1ac440b9db Seems to be working in CPU simulator. Need to remove debug crap
William Morgan <billjunk@mrgn.org>
parents: 28
diff changeset
58 continuations <- fold: continuations [] with: :acc el{
28
75c97fb80602 Tag team simple AI WIP
William Morgan <billjunk@mrgn.org>
parents: 26
diff changeset
59 ret <- acc
75c97fb80602 Tag team simple AI WIP
William Morgan <billjunk@mrgn.org>
parents: 26
diff changeset
60 if: notdone {
75c97fb80602 Tag team simple AI WIP
William Morgan <billjunk@mrgn.org>
parents: 26
diff changeset
61 ret <- el:
75c97fb80602 Tag team simple AI WIP
William Morgan <billjunk@mrgn.org>
parents: 26
diff changeset
62 if: (ret isInteger?) {
31
3812bf35168d Simple AI seems to work now. Lots of debug junk needs to be removed though
Michael Pavone <pavone@retrodev.com>
parents: 30
diff changeset
63 ret <- acc
28
75c97fb80602 Tag team simple AI WIP
William Morgan <billjunk@mrgn.org>
parents: 26
diff changeset
64 } else: {
75c97fb80602 Tag team simple AI WIP
William Morgan <billjunk@mrgn.org>
parents: 26
diff changeset
65 if: (ret value) {
75c97fb80602 Tag team simple AI WIP
William Morgan <billjunk@mrgn.org>
parents: 26
diff changeset
66 notdone <- 0
75c97fb80602 Tag team simple AI WIP
William Morgan <billjunk@mrgn.org>
parents: 26
diff changeset
67 ret <- (ret tail)
75c97fb80602 Tag team simple AI WIP
William Morgan <billjunk@mrgn.org>
parents: 26
diff changeset
68 } else: {
75c97fb80602 Tag team simple AI WIP
William Morgan <billjunk@mrgn.org>
parents: 26
diff changeset
69 ret <- (ret tail) | acc
75c97fb80602 Tag team simple AI WIP
William Morgan <billjunk@mrgn.org>
parents: 26
diff changeset
70 }
75c97fb80602 Tag team simple AI WIP
William Morgan <billjunk@mrgn.org>
parents: 26
diff changeset
71 }
75c97fb80602 Tag team simple AI WIP
William Morgan <billjunk@mrgn.org>
parents: 26
diff changeset
72 } else: {}
29
5d1ac440b9db Seems to be working in CPU simulator. Need to remove debug crap
William Morgan <billjunk@mrgn.org>
parents: 28
diff changeset
73 ret
5d1ac440b9db Seems to be working in CPU simulator. Need to remove debug crap
William Morgan <billjunk@mrgn.org>
parents: 28
diff changeset
74 }
5d1ac440b9db Seems to be working in CPU simulator. Need to remove debug crap
William Morgan <billjunk@mrgn.org>
parents: 28
diff changeset
75 if: notdone {
5d1ac440b9db Seems to be working in CPU simulator. Need to remove debug crap
William Morgan <billjunk@mrgn.org>
parents: 28
diff changeset
76 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
77 } else: {}
24
37158acf31e5 Initial pass at scan loop
William Morgan <billjunk@mrgn.org>
parents: 12
diff changeset
78 }
37158acf31e5 Initial pass at scan loop
William Morgan <billjunk@mrgn.org>
parents: 12
diff changeset
79 }
28
75c97fb80602 Tag team simple AI WIP
William Morgan <billjunk@mrgn.org>
parents: 26
diff changeset
80 continuations
26
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
81 }
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
82
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
83 calcPos <- :move from {
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
84 x <- from value
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
85 y <- from tail
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
86 if: move {
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
87 if: move = 1 {
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
88 x <- x + 1
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
89 } else: {
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
90 if: move = 2 {
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
91 y <- y + 1
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
92 } else: {
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
93 x <- x - 1
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
94 }
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
95 }
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
96 } else: {
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
97 y <- y - 1
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
98 }
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
99 #[x y]
24
37158acf31e5 Initial pass at scan loop
William Morgan <billjunk@mrgn.org>
parents: 12
diff changeset
100 }
26
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
101
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
102 makeContClos <- :grid myLoc path {
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
103 {
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
104 ret <- []
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
105 move <- 0
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
106 atpos <- 0
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
107 if: (grid: grid inBounds?: myLoc) {
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
108 if: (grid: visited get: myLoc) {
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
109 } else: {
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
110 atpos <- grid: grid get: myLoc
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
111 if: (atpos = 2) + (atpos = 3) + (atpos = 4) {
34
968705fcb4c6 Initial stab at taking fruit and ghost state into account
Michael Pavone <pavone@retrodev.com>
parents: 32
diff changeset
112 //pellet, power pellet, fruit
26
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
113 ret <- #[1 (reverse: path)]
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
114 } else: {
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
115 visited <- grid: visited set: myLoc to: 1
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
116 if: atpos {
34
968705fcb4c6 Initial stab at taking fruit and ghost state into account
Michael Pavone <pavone@retrodev.com>
parents: 32
diff changeset
117 //empty space
26
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
118 move <- 0
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
119 while: { move < 4 } do: {
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
120 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
121 move <- move + 1
26
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
122 }
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
123 ret <- #[0 ret]
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
124 } else: {}
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
125 }
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
126 }
28
75c97fb80602 Tag team simple AI WIP
William Morgan <billjunk@mrgn.org>
parents: 26
diff changeset
127 } else: {
75c97fb80602 Tag team simple AI WIP
William Morgan <billjunk@mrgn.org>
parents: 26
diff changeset
128 }
26
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
129 ret
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
130 }
24
37158acf31e5 Initial pass at scan loop
William Morgan <billjunk@mrgn.org>
parents: 12
diff changeset
131 }
37158acf31e5 Initial pass at scan loop
William Morgan <billjunk@mrgn.org>
parents: 12
diff changeset
132
12
1c6d4f2642d0 Fist progress toward a simple recursive dot scanner bot
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
133 step <- :myState world {
28
75c97fb80602 Tag team simple AI WIP
William Morgan <billjunk@mrgn.org>
parents: 26
diff changeset
134 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
135 myLoc <- (lmState tail) value
34
968705fcb4c6 Initial stab at taking fruit and ghost state into account
Michael Pavone <pavone@retrodev.com>
parents: 32
diff changeset
136 ghostState <- ((world tail) tail) value
968705fcb4c6 Initial stab at taking fruit and ghost state into account
Michael Pavone <pavone@retrodev.com>
parents: 32
diff changeset
137 fruitState <- ((world tail) tail) tail
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
138
34
968705fcb4c6 Initial stab at taking fruit and ghost state into account
Michael Pavone <pavone@retrodev.com>
parents: 32
diff changeset
139 grid <- makeTree: (map: (world value) :row {
968705fcb4c6 Initial stab at taking fruit and ghost state into account
Michael Pavone <pavone@retrodev.com>
parents: 32
diff changeset
140 if: fruitState >= 127 {
968705fcb4c6 Initial stab at taking fruit and ghost state into account
Michael Pavone <pavone@retrodev.com>
parents: 32
diff changeset
141 } else: {
968705fcb4c6 Initial stab at taking fruit and ghost state into account
Michael Pavone <pavone@retrodev.com>
parents: 32
diff changeset
142 row <- map: row :el {
968705fcb4c6 Initial stab at taking fruit and ghost state into account
Michael Pavone <pavone@retrodev.com>
parents: 32
diff changeset
143 //remove fruit if it is not enabled
968705fcb4c6 Initial stab at taking fruit and ghost state into account
Michael Pavone <pavone@retrodev.com>
parents: 32
diff changeset
144 if: el = 4 {
968705fcb4c6 Initial stab at taking fruit and ghost state into account
Michael Pavone <pavone@retrodev.com>
parents: 32
diff changeset
145 el <- 1
968705fcb4c6 Initial stab at taking fruit and ghost state into account
Michael Pavone <pavone@retrodev.com>
parents: 32
diff changeset
146 } else: {}
968705fcb4c6 Initial stab at taking fruit and ghost state into account
Michael Pavone <pavone@retrodev.com>
parents: 32
diff changeset
147 el
968705fcb4c6 Initial stab at taking fruit and ghost state into account
Michael Pavone <pavone@retrodev.com>
parents: 32
diff changeset
148 }
968705fcb4c6 Initial stab at taking fruit and ghost state into account
Michael Pavone <pavone@retrodev.com>
parents: 32
diff changeset
149 }
968705fcb4c6 Initial stab at taking fruit and ghost state into account
Michael Pavone <pavone@retrodev.com>
parents: 32
diff changeset
150 makeTree: row
968705fcb4c6 Initial stab at taking fruit and ghost state into account
Michael Pavone <pavone@retrodev.com>
parents: 32
diff changeset
151 })
968705fcb4c6 Initial stab at taking fruit and ghost state into account
Michael Pavone <pavone@retrodev.com>
parents: 32
diff changeset
152 grid <- fold: ghostState grid with: :acc ghost {
968705fcb4c6 Initial stab at taking fruit and ghost state into account
Michael Pavone <pavone@retrodev.com>
parents: 32
diff changeset
153 vitality <- ghost value
968705fcb4c6 Initial stab at taking fruit and ghost state into account
Michael Pavone <pavone@retrodev.com>
parents: 32
diff changeset
154 loc <- (ghost tail) value
35
8c26981aae8c Last fixes for lightning round version of dotScanner.lm
Michael Pavone <pavone@retrodev.com>
parents: 34
diff changeset
155 dir <- (ghost tail) tail
8c26981aae8c Last fixes for lightning round version of dotScanner.lm
Michael Pavone <pavone@retrodev.com>
parents: 34
diff changeset
156 nextloc <- 0
8c26981aae8c Last fixes for lightning round version of dotScanner.lm
Michael Pavone <pavone@retrodev.com>
parents: 34
diff changeset
157 move <- 0
34
968705fcb4c6 Initial stab at taking fruit and ghost state into account
Michael Pavone <pavone@retrodev.com>
parents: 32
diff changeset
158 if: vitality = 1 {
968705fcb4c6 Initial stab at taking fruit and ghost state into account
Michael Pavone <pavone@retrodev.com>
parents: 32
diff changeset
159 //treat fright mode ghosts as a pellet for now
968705fcb4c6 Initial stab at taking fruit and ghost state into account
Michael Pavone <pavone@retrodev.com>
parents: 32
diff changeset
160 acc <- grid: acc set: loc to: 2
968705fcb4c6 Initial stab at taking fruit and ghost state into account
Michael Pavone <pavone@retrodev.com>
parents: 32
diff changeset
161 } else: {
968705fcb4c6 Initial stab at taking fruit and ghost state into account
Michael Pavone <pavone@retrodev.com>
parents: 32
diff changeset
162 if: vitality = 0 {
968705fcb4c6 Initial stab at taking fruit and ghost state into account
Michael Pavone <pavone@retrodev.com>
parents: 32
diff changeset
163 //treat normal mode ghosts as a wall for now
968705fcb4c6 Initial stab at taking fruit and ghost state into account
Michael Pavone <pavone@retrodev.com>
parents: 32
diff changeset
164 acc <- grid: acc set: loc to: 0
35
8c26981aae8c Last fixes for lightning round version of dotScanner.lm
Michael Pavone <pavone@retrodev.com>
parents: 34
diff changeset
165 while: { move < 4 } do: {
8c26981aae8c Last fixes for lightning round version of dotScanner.lm
Michael Pavone <pavone@retrodev.com>
parents: 34
diff changeset
166 nextloc <- calcPos: move loc
8c26981aae8c Last fixes for lightning round version of dotScanner.lm
Michael Pavone <pavone@retrodev.com>
parents: 34
diff changeset
167 if: (grid: acc inBounds?: nextloc) {
8c26981aae8c Last fixes for lightning round version of dotScanner.lm
Michael Pavone <pavone@retrodev.com>
parents: 34
diff changeset
168 acc <- grid: acc set: nextloc to: 0
8c26981aae8c Last fixes for lightning round version of dotScanner.lm
Michael Pavone <pavone@retrodev.com>
parents: 34
diff changeset
169 } else: {}
8c26981aae8c Last fixes for lightning round version of dotScanner.lm
Michael Pavone <pavone@retrodev.com>
parents: 34
diff changeset
170 move <- move + 1
8c26981aae8c Last fixes for lightning round version of dotScanner.lm
Michael Pavone <pavone@retrodev.com>
parents: 34
diff changeset
171 }
34
968705fcb4c6 Initial stab at taking fruit and ghost state into account
Michael Pavone <pavone@retrodev.com>
parents: 32
diff changeset
172 } else: {}
968705fcb4c6 Initial stab at taking fruit and ghost state into account
Michael Pavone <pavone@retrodev.com>
parents: 32
diff changeset
173 }
968705fcb4c6 Initial stab at taking fruit and ghost state into account
Michael Pavone <pavone@retrodev.com>
parents: 32
diff changeset
174 acc
968705fcb4c6 Initial stab at taking fruit and ghost state into account
Michael Pavone <pavone@retrodev.com>
parents: 32
diff changeset
175 }
35
8c26981aae8c Last fixes for lightning round version of dotScanner.lm
Michael Pavone <pavone@retrodev.com>
parents: 34
diff changeset
176 //make sure my location is marked clear even if there is a ghost nearby
8c26981aae8c Last fixes for lightning round version of dotScanner.lm
Michael Pavone <pavone@retrodev.com>
parents: 34
diff changeset
177 grid <- grid: grid set: myLoc to: 1
28
75c97fb80602 Tag team simple AI WIP
William Morgan <billjunk@mrgn.org>
parents: 26
diff changeset
178 visited <- treeMap: grid :row {
75c97fb80602 Tag team simple AI WIP
William Morgan <billjunk@mrgn.org>
parents: 26
diff changeset
179 treeMap: row :el { 0 }
75c97fb80602 Tag team simple AI WIP
William Morgan <billjunk@mrgn.org>
parents: 26
diff changeset
180 }
75c97fb80602 Tag team simple AI WIP
William Morgan <billjunk@mrgn.org>
parents: 26
diff changeset
181 path <- advancer: [(makeContClos: grid myLoc [])]
35
8c26981aae8c Last fixes for lightning round version of dotScanner.lm
Michael Pavone <pavone@retrodev.com>
parents: 34
diff changeset
182 if: (path isInteger?) {
8c26981aae8c Last fixes for lightning round version of dotScanner.lm
Michael Pavone <pavone@retrodev.com>
parents: 34
diff changeset
183 print: 42
8c26981aae8c Last fixes for lightning round version of dotScanner.lm
Michael Pavone <pavone@retrodev.com>
parents: 34
diff changeset
184 path <- [0]
8c26981aae8c Last fixes for lightning round version of dotScanner.lm
Michael Pavone <pavone@retrodev.com>
parents: 34
diff changeset
185 } else: {}
28
75c97fb80602 Tag team simple AI WIP
William Morgan <billjunk@mrgn.org>
parents: 26
diff changeset
186 #[0 (path value)]
12
1c6d4f2642d0 Fist progress toward a simple recursive dot scanner bot
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
187 }
1c6d4f2642d0 Fist progress toward a simple recursive dot scanner bot
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
188
30
3287eb6c25fe Sort of working in the game simulator!!!!!
William Morgan <billjunk@mrgn.org>
parents: 29
diff changeset
189 main <- :initWorld ghostCode {
3287eb6c25fe Sort of working in the game simulator!!!!!
William Morgan <billjunk@mrgn.org>
parents: 29
diff changeset
190 /*
29
5d1ac440b9db Seems to be working in CPU simulator. Need to remove debug crap
William Morgan <billjunk@mrgn.org>
parents: 28
diff changeset
191 print: (step: 0 #[
34
968705fcb4c6 Initial stab at taking fruit and ghost state into account
Michael Pavone <pavone@retrodev.com>
parents: 32
diff changeset
192 //grid
29
5d1ac440b9db Seems to be working in CPU simulator. Need to remove debug crap
William Morgan <billjunk@mrgn.org>
parents: 28
diff changeset
193 [
5d1ac440b9db Seems to be working in CPU simulator. Need to remove debug crap
William Morgan <billjunk@mrgn.org>
parents: 28
diff changeset
194 [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
195 [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
196 [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
197 [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
198 ]
34
968705fcb4c6 Initial stab at taking fruit and ghost state into account
Michael Pavone <pavone@retrodev.com>
parents: 32
diff changeset
199 //lmstate
29
5d1ac440b9db Seems to be working in CPU simulator. Need to remove debug crap
William Morgan <billjunk@mrgn.org>
parents: 28
diff changeset
200 #[0 #[1 2] 2 3 0]
34
968705fcb4c6 Initial stab at taking fruit and ghost state into account
Michael Pavone <pavone@retrodev.com>
parents: 32
diff changeset
201 //ghost state
29
5d1ac440b9db Seems to be working in CPU simulator. Need to remove debug crap
William Morgan <billjunk@mrgn.org>
parents: 28
diff changeset
202 []
34
968705fcb4c6 Initial stab at taking fruit and ghost state into account
Michael Pavone <pavone@retrodev.com>
parents: 32
diff changeset
203 //fruit state
29
5d1ac440b9db Seems to be working in CPU simulator. Need to remove debug crap
William Morgan <billjunk@mrgn.org>
parents: 28
diff changeset
204 0
30
3287eb6c25fe Sort of working in the game simulator!!!!!
William Morgan <billjunk@mrgn.org>
parents: 29
diff changeset
205 ]) */
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
206 #[0 step]
12
1c6d4f2642d0 Fist progress toward a simple recursive dot scanner bot
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
207 }
1c6d4f2642d0 Fist progress toward a simple recursive dot scanner bot
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
208 }
1c6d4f2642d0 Fist progress toward a simple recursive dot scanner bot
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
209
1c6d4f2642d0 Fist progress toward a simple recursive dot scanner bot
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
210