Mercurial > repos > icfp2014
changeset 34:968705fcb4c6
Initial stab at taking fruit and ghost state into account
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Sat, 26 Jul 2014 01:41:24 -0700 |
parents | 934d03d42a7e |
children | 8c26981aae8c |
files | code/dotScanner.lm |
diffstat | 1 files changed, 35 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/code/dotScanner.lm Sat Jul 26 01:02:41 2014 -0700 +++ b/code/dotScanner.lm Sat Jul 26 01:41:24 2014 -0700 @@ -260,10 +260,12 @@ } else: { atpos <- grid: grid get: myLoc if: (atpos = 2) + (atpos = 3) + (atpos = 4) { + //pellet, power pellet, fruit ret <- #[1 (reverse: path)] } else: { visited <- grid: visited set: myLoc to: 1 if: atpos { + //empty space move <- 0 while: { move < 4 } do: { ret <- (makeContClos: grid (calcPos: move myLoc) move | path) | ret @@ -280,10 +282,38 @@ } step <- :myState world { - grid <- makeTree: (map: (world value) :row { makeTree: row }) lmState <- (world tail) value myLoc <- (lmState tail) value + ghostState <- ((world tail) tail) value + fruitState <- ((world tail) tail) tail + grid <- makeTree: (map: (world value) :row { + if: fruitState >= 127 { + } else: { + row <- map: row :el { + //remove fruit if it is not enabled + if: el = 4 { + el <- 1 + } else: {} + el + } + } + makeTree: row + }) + grid <- fold: ghostState grid with: :acc ghost { + vitality <- ghost value + loc <- (ghost tail) value + if: vitality = 1 { + //treat fright mode ghosts as a pellet for now + acc <- grid: acc set: loc to: 2 + } else: { + if: vitality = 0 { + //treat normal mode ghosts as a wall for now + acc <- grid: acc set: loc to: 0 + } else: {} + } + acc + } visited <- treeMap: grid :row { treeMap: row :el { 0 } } @@ -294,14 +324,18 @@ main <- :initWorld ghostCode { /* print: (step: 0 #[ + //grid [ [0 0 0 0] [0 2 2 0] [0 1 0 0] [0 0 0 0] ] + //lmstate #[0 #[1 2] 2 3 0] + //ghost state [] + //fruit state 0 ]) */ #[0 step]