aboutsummaryrefslogtreecommitdiff
path: root/src/pinky.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/pinky.py')
-rw-r--r--src/pinky.py23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/pinky.py b/src/pinky.py
index 29949a7..bb50c5b 100644
--- a/src/pinky.py
+++ b/src/pinky.py
@@ -43,7 +43,11 @@ class Pinky(Ghost):
return (27 * 30 + 15, 30 * 30 + 15)
@override
- def get_next_move(self, pacman, maze, screen, blinky):
+ def get_intial_tile(self):
+ return (11 * 30 + 15, 12 * 30 + 15)
+
+ @override
+ def get_next_move(self, game_state, screen):
default_tile = self.get_default_tile()
dx = [1, 0, -1, 0]
@@ -64,25 +68,20 @@ class Pinky(Ghost):
rand_pos = (0, 0)
- new_target = self.get_four_tiles_ahead_of_pacman(pacman)
- if settings.debug:
- pygame.draw.circle(screen, self.color,
- (new_target[0], new_target[1]), 15)
- pygame.draw.circle(screen, self.color,
- default_tile, 15)
+ new_target = self.get_four_tiles_ahead_of_pacman(game_state.pacman)
- if pacman.powerup:
+ if game_state.pacman.powerup and self.mode != MODE.EATEN:
self.mode = MODE.FRIGHETENED
rand_pos = random.randint(0, 900), random.randint(0, 990)
- if pacman.powerup is False and self.mode == MODE.FRIGHETENED:
+ if game_state.pacman.powerup is False and self.mode == MODE.FRIGHETENED:
self.mode = MODE.CHASING
for i in range(len(dx)):
if i != forbidden:
nx = self.x + dx[i] * self.speed
ny = self.y + dy[i] * self.speed
- if self.check_collision(nx, ny, 30, 30, maze):
+ if self.check_collision(nx, ny, 30, 30, game_state.map.maze):
if self.mode == MODE.SCATTERED:
ret[i] = self.heuristic(
(nx, ny), default_tile[0], default_tile[1])
@@ -92,6 +91,10 @@ class Pinky(Ghost):
elif self.mode == MODE.CHASING:
ret[i] = self.heuristic(
(nx, ny), new_target[0], new_target[1])
+ elif self.mode == MODE.EATEN:
+ pos = self.get_intial_tile()
+ self.x = pos[0]
+ self.y = pos[1]
if settings.debug:
pygame.draw.line(screen, self.color, (new_target),
(self.x, self.y), 1)