Mercurial > repos > icfp2014
comparison code/dotScanner.lm @ 35:8c26981aae8c
Last fixes for lightning round version of dotScanner.lm
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Sat, 26 Jul 2014 03:17:58 -0700 |
parents | 968705fcb4c6 |
children | d5ccb66ae98b |
comparison
equal
deleted
inserted
replaced
34:968705fcb4c6 | 35:8c26981aae8c |
---|---|
301 makeTree: row | 301 makeTree: row |
302 }) | 302 }) |
303 grid <- fold: ghostState grid with: :acc ghost { | 303 grid <- fold: ghostState grid with: :acc ghost { |
304 vitality <- ghost value | 304 vitality <- ghost value |
305 loc <- (ghost tail) value | 305 loc <- (ghost tail) value |
306 dir <- (ghost tail) tail | |
307 nextloc <- 0 | |
308 move <- 0 | |
306 if: vitality = 1 { | 309 if: vitality = 1 { |
307 //treat fright mode ghosts as a pellet for now | 310 //treat fright mode ghosts as a pellet for now |
308 acc <- grid: acc set: loc to: 2 | 311 acc <- grid: acc set: loc to: 2 |
309 } else: { | 312 } else: { |
310 if: vitality = 0 { | 313 if: vitality = 0 { |
311 //treat normal mode ghosts as a wall for now | 314 //treat normal mode ghosts as a wall for now |
312 acc <- grid: acc set: loc to: 0 | 315 acc <- grid: acc set: loc to: 0 |
316 while: { move < 4 } do: { | |
317 nextloc <- calcPos: move loc | |
318 if: (grid: acc inBounds?: nextloc) { | |
319 acc <- grid: acc set: nextloc to: 0 | |
320 } else: {} | |
321 move <- move + 1 | |
322 } | |
313 } else: {} | 323 } else: {} |
314 } | 324 } |
315 acc | 325 acc |
316 } | 326 } |
327 //make sure my location is marked clear even if there is a ghost nearby | |
328 grid <- grid: grid set: myLoc to: 1 | |
317 visited <- treeMap: grid :row { | 329 visited <- treeMap: grid :row { |
318 treeMap: row :el { 0 } | 330 treeMap: row :el { 0 } |
319 } | 331 } |
320 path <- advancer: [(makeContClos: grid myLoc [])] | 332 path <- advancer: [(makeContClos: grid myLoc [])] |
333 if: (path isInteger?) { | |
334 print: 42 | |
335 path <- [0] | |
336 } else: {} | |
321 #[0 (path value)] | 337 #[0 (path value)] |
322 } | 338 } |
323 | 339 |
324 main <- :initWorld ghostCode { | 340 main <- :initWorld ghostCode { |
325 /* | 341 /* |