comparison code/dotScanner.lm @ 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 57a4bddadd46
children 47eb447a74cc
comparison
equal deleted inserted replaced
74:10a75a37c0fa 75:6df7f6372d29
31 grid:inBounds? 31 grid:inBounds?
32 calcPos 32 calcPos
33 ] from: (module: "grid.lm") 33 ] from: (module: "grid.lm")
34 34
35 visited <- 0 35 visited <- 0
36 badGhostCount <- 0
36 37
37 advancer <- :continuations { 38 advancer <- :continuations {
38 notdone <- 1 39 notdone <- 1
39 while: { notdone } do: { 40 while: { notdone } do: {
40 if: (continuations isInteger?) { 41 if: (continuations isInteger?) {
72 atpos <- 0 73 atpos <- 0
73 if: (grid: grid inBounds?: myLoc) { 74 if: (grid: grid inBounds?: myLoc) {
74 if: (grid: visited get: myLoc) { 75 if: (grid: visited get: myLoc) {
75 } else: { 76 } else: {
76 atpos <- grid: grid get: myLoc 77 atpos <- grid: grid get: myLoc
78 if: badGhostCount > 0 {
79 } else: {
80 //treat power pellets as empty space when there are no ghosts in normal mode
81 if: (atpos = 3) {
82 atpos <- 1
83 } else: {}
84 }
77 if: (atpos = 2) + (atpos = 3) + (atpos = 4) { 85 if: (atpos = 2) + (atpos = 3) + (atpos = 4) {
78 //pellet, power pellet, fruit 86 //pellet, power pellet, fruit
79 ret <- #[1 (reverse: path)] 87 ret <- #[1 (reverse: path)]
80 } else: { 88 } else: {
81 visited <- grid: visited set: myLoc to: 1 89 visited <- grid: visited set: myLoc to: 1
113 el 121 el
114 } 122 }
115 } 123 }
116 makeTree: row 124 makeTree: row
117 }) 125 })
126 badGhostCount <- 0
118 grid <- fold: ghostState grid with: :acc ghost { 127 grid <- fold: ghostState grid with: :acc ghost {
119 vitality <- ghost value 128 vitality <- ghost value
120 loc <- (ghost tail) value 129 loc <- (ghost tail) value
121 dir <- (ghost tail) tail 130 dir <- (ghost tail) tail
122 nextloc <- 0 131 nextloc <- 0
124 if: vitality = 1 { 133 if: vitality = 1 {
125 //treat fright mode ghosts as a pellet for now 134 //treat fright mode ghosts as a pellet for now
126 acc <- grid: acc set: loc to: 2 135 acc <- grid: acc set: loc to: 2
127 } else: { 136 } else: {
128 if: vitality = 0 { 137 if: vitality = 0 {
138 badGhostCount <- badGhostCount + 1
129 //treat normal mode ghosts as a wall for now 139 //treat normal mode ghosts as a wall for now
130 acc <- grid: acc set: loc to: 0 140 acc <- grid: acc set: loc to: 0
131 while: { move < 4 } do: { 141 while: { move < 4 } do: {
132 nextloc <- calcPos: move loc 142 nextloc <- calcPos: move loc
133 if: (grid: acc inBounds?: nextloc) { 143 if: (grid: acc inBounds?: nextloc) {