changeset 75:6df7f6372d29

Small tweak to dotScanner lambda man AI to ignore power pellets when it would be wasteful to eat them
author Michael Pavone <pavone@retrodev.com>
date Mon, 28 Jul 2014 02:12:10 -0700
parents 10a75a37c0fa
children 47eb447a74cc
files code/dotScanner.lm
diffstat 1 files changed, 10 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/code/dotScanner.lm	Mon Jul 28 01:03:11 2014 -0700
+++ b/code/dotScanner.lm	Mon Jul 28 02:12:10 2014 -0700
@@ -33,6 +33,7 @@
 	] from: (module: "grid.lm")
 
 	visited <- 0
+	badGhostCount <- 0
 
 	advancer <- :continuations {
 		notdone <- 1
@@ -74,6 +75,13 @@
 				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: (atpos = 2) + (atpos = 3) + (atpos = 4) {
 						//pellet, power pellet, fruit
 						ret <- #[1 (reverse: path)]
@@ -115,6 +123,7 @@
 			}
 			makeTree: row 
 		})
+		badGhostCount <- 0
 		grid <- fold: ghostState grid with: :acc ghost {
 			vitality <- ghost value
 			loc <- (ghost tail) value
@@ -126,6 +135,7 @@
 				acc <- grid: acc set: loc to: 2
 			} else: {
 				if: vitality = 0 {
+					badGhostCount <- badGhostCount + 1
 					//treat normal mode ghosts as a wall for now
 					acc <- grid: acc set: loc to: 0
 					while: { move < 4 } do: {