# HG changeset patch # User Michael Pavone # Date 1406541476 25200 # Node ID 47eb447a74cc589ef9428e4adf738683b779e83a # Parent 6df7f6372d29bb0c75a1c431fc55944cf528c94c Don't chase ghosts we can't catch diff -r 6df7f6372d29 -r 47eb447a74cc code/dotScanner.lm --- a/code/dotScanner.lm Mon Jul 28 02:12:10 2014 -0700 +++ b/code/dotScanner.lm Mon Jul 28 02:57:56 2014 -0700 @@ -34,6 +34,7 @@ visited <- 0 badGhostCount <- 0 + edibleGhosts <- 0 advancer <- :continuations { notdone <- 1 @@ -80,9 +81,15 @@ //treat power pellets as empty space when there are no ghosts in normal mode if: (atpos = 3) { atpos <- 1 - } else: {} + } else: { + if: edibleGhosts > 0 { + if: (atpos = 2) { + atpos <- 1 + } else: {} + } else: {} + } } - if: (atpos = 2) + (atpos = 3) + (atpos = 4) { + if: (atpos = 2) + (atpos = 3) + (atpos = 4) + (atpos = 7) { //pellet, power pellet, fruit ret <- #[1 (reverse: path)] } else: { @@ -106,6 +113,7 @@ step <- :myState world { lmState <- (world tail) value + myVitality <- lmState value myLoc <- (lmState tail) value ghostState <- ((world tail) tail) value fruitState <- ((world tail) tail) tail @@ -124,15 +132,31 @@ makeTree: row }) badGhostCount <- 0 + edibleGhosts <- 0 grid <- fold: ghostState grid with: :acc ghost { vitality <- ghost value loc <- (ghost tail) value dir <- (ghost tail) tail nextloc <- 0 move <- 0 + manHatDist <- 0 if: vitality = 1 { - //treat fright mode ghosts as a pellet for now - acc <- grid: acc set: loc to: 2 + + if: (myLoc value) > (loc value) { + manHatDist <- (myLoc value) - (loc value) + } else: { + manHatDist <- (loc value) - (myLoc value) + } + if: (myLoc tail) > (loc tail) { + manHatDist <- manHatDist + (myLoc tail) - (loc tail) + } else: { + manHatDist <- manHatDist + (loc tail) - (myLoc tail) + } + if: myVitality > (manHatDist * 254) { + edibleGhosts <- edibleGhosts + 1 + } else: {} + //mark fright mode ghosts + acc <- grid: acc set: loc to: 7 } else: { if: vitality = 0 { badGhostCount <- badGhostCount + 1 @@ -141,7 +165,13 @@ while: { move < 4 } do: { nextloc <- calcPos: move loc if: (grid: acc inBounds?: nextloc) { - acc <- grid: acc set: nextloc to: 0 + acc <- grid: acc update: nextloc with: :oldval { + if: oldval = 3 { + } else: { + oldval <- 0 + } + oldval + } } else: {} move <- move + 1 }