aboutsummaryrefslogtreecommitdiff
path: root/src/pinky.py
diff options
context:
space:
mode:
authoromagdy7 <omar.professional8777@gmail.com>2023-04-19 05:20:26 +0200
committeromagdy7 <omar.professional8777@gmail.com>2023-04-19 05:20:26 +0200
commit4fe339692233290a5d074533b4f4ebea668f8832 (patch)
tree75e56e2e4a4fc767d17d0aa9ac651c9f69a60030 /src/pinky.py
parent7e4ef8be6fdce53ad01cacec3a9a9ed157d161b7 (diff)
downloadMacpan-4fe339692233290a5d074533b4f4ebea668f8832.tar.xz
Macpan-4fe339692233290a5d074533b4f4ebea668f8832.zip
Fixed a bug in pacman position not updating proberly in the heueristic function
Diffstat (limited to 'src/pinky.py')
-rw-r--r--src/pinky.py9
1 files changed, 3 insertions, 6 deletions
diff --git a/src/pinky.py b/src/pinky.py
index f89865d..c8324bb 100644
--- a/src/pinky.py
+++ b/src/pinky.py
@@ -9,12 +9,8 @@ class Pinky(Ghost):
super().__init__(sprite_sheet,"pink", x, y)
-
- def in_bounds(self, pos):
- return pos[0] >= 0 and pos[1] >= 0 and pos[0] < settings.width and pos[1] < settings.height
-
-
def get_four_tiles_ahead_of_pacman(self, pacman):
+ print("Before", pacman.x, pacman.y)
if pacman.direction == DIRECTION.UP:
new_target = (pacman.x - 30 * 4, pacman.y - 30 * 4)
if self.in_bounds(new_target):
@@ -59,13 +55,14 @@ class Pinky(Ghost):
forbidden = 1
new_target = self.get_four_tiles_ahead_of_pacman(target)
+ print("After: ", new_target)
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):
- ret[i] = self.heuristic((nx, ny), new_target)
+ ret[i] = self.heuristic((nx, ny), new_target[0], new_target[1])
min_idx = ret.index(min(ret))
return min_idx