# HG changeset patch # User Michael Pavone # Date 1406543061 25200 # Node ID dcfa9797607125be7fd135f32e900a83c0310090 # Parent 3b8a277decfa353c6566f3aac937023d0c7802a7 Better handling of target selection diff -r 3b8a277decfa -r dcfa97976071 code/dotScanner.lm --- a/code/dotScanner.lm Mon Jul 28 03:11:01 2014 -0700 +++ b/code/dotScanner.lm Mon Jul 28 03:24:21 2014 -0700 @@ -35,6 +35,7 @@ visited <- 0 badGhostCount <- 0 edibleGhosts <- 0 + totalGhosts <- 0 advancer <- :continuations { notdone <- 1 @@ -66,6 +67,11 @@ } continuations } + + target0 <- 2 + target1 <- 3 + target2 <- 4 + target3 <- 7 makeContClos <- :grid myLoc path { { @@ -76,20 +82,7 @@ if: (grid: visited get: myLoc) { } else: { atpos <- grid: grid get: myLoc - if: badGhostCount > 0 { - } else: { - //treat power pellets as empty space when there are no ghosts in normal mode - if: (atpos = 3) { - atpos <- 1 - } else: { - if: edibleGhosts > 0 { - if: (atpos = 2) { - atpos <- 1 - } else: {} - } else: {} - } - } - if: (atpos = 2) + (atpos = 3) + (atpos = 4) + (atpos = 7) { + if: (atpos = target0) + (atpos = target1) + (atpos = target2) + (atpos = target3) { //pellet, power pellet, fruit ret <- #[1 (reverse: path)] } else: { @@ -133,7 +126,9 @@ }) badGhostCount <- 0 edibleGhosts <- 0 + totalGhosts <- 0 grid <- fold: ghostState grid with: :acc ghost { + totalGhosts <- totalGhosts + 1 vitality <- ghost value loc <- (ghost tail) value dir <- (ghost tail) tail @@ -179,6 +174,24 @@ } acc } + //default behavior, target all yummy things + target0 <- 2 + target1 <- 3 + target2 <- 4 + target3 <- 7 + if: badGhostCount > 0 { + } else: { + if: totalGhosts > 0 { + //ignore power pellets when there are no ghosts in normal mode + target1 <- 2 + if: edibleGhosts > 0 { + //ignore anything except edible ghosts when some are in range + target0 <- 7 + target1 <- 7 + target2 <- 7 + } else: {} + } else: {} + } //make sure my location is marked clear even if there is a ghost nearby grid <- grid: grid set: myLoc to: 1 visited <- treeMap: grid :row {