comparison code/dotScanner.lm @ 30:3287eb6c25fe

Sort of working in the game simulator!!!!!
author William Morgan <billjunk@mrgn.org>
date Sat, 26 Jul 2014 00:23:19 -0700
parents 5d1ac440b9db
children 3812bf35168d
comparison
equal deleted inserted replaced
29:5d1ac440b9db 30:3287eb6c25fe
171 tree:set:to <- :tree :idx :val { 171 tree:set:to <- :tree :idx :val {
172 tree: tree update: idx with: :el { val } 172 tree: tree update: idx with: :el { val }
173 } 173 }
174 174
175 grid:get <- :grid :pos { 175 grid:get <- :grid :pos {
176 print: #[15 pos]
177 x <- pos value 176 x <- pos value
178 y <- pos tail 177 y <- pos tail
179 get: x fromTree: (get: y fromTree: grid) 178 get: x fromTree: (get: y fromTree: grid)
180 } 179 }
181 180
200 } 199 }
201 200
202 visited <- 0 201 visited <- 0
203 202
204 advancer <- :continuations { 203 advancer <- :continuations {
205 print: 5
206 notdone <- 1 204 notdone <- 1
207 while: { notdone } do: { 205 while: { notdone } do: {
208 if: (continuations isInteger?) { 206 if: (continuations isInteger?) {
209 notdone <- 0 207 notdone <- 0
210 } else: { 208 } else: {
211 print: #[6 continuations]
212 continuations <- fold: continuations [] with: :acc el{ 209 continuations <- fold: continuations [] with: :acc el{
213 print: 7
214 ret <- acc 210 ret <- acc
215 if: notdone { 211 if: notdone {
216 print: 25
217 ret <- el: 212 ret <- el:
218 if: (ret isInteger?) { 213 if: (ret isInteger?) {
219 } else: { 214 } else: {
220 print: #[26 ret]
221 if: (ret value) { 215 if: (ret value) {
222 print: 27
223 notdone <- 0 216 notdone <- 0
224 ret <- (ret tail) 217 ret <- (ret tail)
225 } else: { 218 } else: {
226 print: 28
227 ret <- (ret tail) | acc 219 ret <- (ret tail) | acc
228 } 220 }
229 } 221 }
230 } else: {} 222 } else: {}
231 ret 223 ret
260 makeContClos <- :grid myLoc path { 252 makeContClos <- :grid myLoc path {
261 { 253 {
262 ret <- [] 254 ret <- []
263 move <- 0 255 move <- 0
264 atpos <- 0 256 atpos <- 0
265 print: 9
266 if: (grid: grid inBounds?: myLoc) { 257 if: (grid: grid inBounds?: myLoc) {
267 print: 10
268 if: (grid: visited get: myLoc) { 258 if: (grid: visited get: myLoc) {
269 } else: { 259 } else: {
270 print: 11
271 atpos <- grid: grid get: myLoc 260 atpos <- grid: grid get: myLoc
272 if: (atpos = 2) + (atpos = 3) + (atpos = 4) { 261 if: (atpos = 2) + (atpos = 3) + (atpos = 4) {
273 print: 12
274 ret <- #[1 (reverse: path)] 262 ret <- #[1 (reverse: path)]
275 } else: { 263 } else: {
276 print: 13
277 visited <- grid: visited set: myLoc to: 1 264 visited <- grid: visited set: myLoc to: 1
278 if: atpos { 265 if: atpos {
279 print: 14
280 move <- 0 266 move <- 0
281 while: { move < 4 } do: { 267 while: { move < 4 } do: {
282 ret <- (makeContClos: grid (calcPos: move myLoc) move | path) | ret 268 ret <- (makeContClos: grid (calcPos: move myLoc) move | path) | ret
283 move <- move + 1 269 move <- move + 1
284 } 270 }
285 ret <- #[0 ret] 271 ret <- #[0 ret]
286 print: 21
287 } else: {} 272 } else: {}
288 } 273 }
289 } 274 }
290 } else: { 275 } else: {
291 print: 42
292 } 276 }
293 ret 277 ret
294 } 278 }
295 } 279 }
296 280
297 step <- :myState world { 281 step <- :myState world {
298 print: -1
299 grid <- makeTree: (map: (world value) :row { makeTree: row }) 282 grid <- makeTree: (map: (world value) :row { makeTree: row })
300 print: 0
301 lmState <- (world tail) value 283 lmState <- (world tail) value
302 print: 1
303 myLoc <- (lmState tail) value 284 myLoc <- (lmState tail) value
304 285
305 print: 2
306 visited <- treeMap: grid :row { 286 visited <- treeMap: grid :row {
307 treeMap: row :el { 0 } 287 treeMap: row :el { 0 }
308 } 288 }
309 print: 3
310 path <- advancer: [(makeContClos: grid myLoc [])] 289 path <- advancer: [(makeContClos: grid myLoc [])]
311 print: #[4 path]
312 #[0 (path value)] 290 #[0 (path value)]
313 } 291 }
314 292
315 main <- { 293 main <- :initWorld ghostCode {
294 /*
316 print: (step: 0 #[ 295 print: (step: 0 #[
317 [ 296 [
318 [0 0 0 0] 297 [0 0 0 0]
319 [0 2 2 0] 298 [0 2 2 0]
320 [0 1 0 0] 299 [0 1 0 0]
321 [0 0 0 0] 300 [0 0 0 0]
322 ] 301 ]
323 #[0 #[1 2] 2 3 0] 302 #[0 #[1 2] 2 3 0]
324 [] 303 []
325 0 304 0
326 ]) 305 ]) */
327 #[0 step] 306 #[0 step]
328 } 307 }
329 } 308 }
330 309
331 310