Skip to content

Commit 831ab4e

Browse files
authored
Implement game logic for ghost interactions
1 parent 9eb657d commit 831ab4e

1 file changed

Lines changed: 14 additions & 9 deletions

File tree

exercises/concept/ghost-gobble-arcade-game/arcade_game.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,12 @@ def eat_ghost(power_pellet_active, touching_ghost):
1212
bool: Can a ghost be eaten?
1313
1414
"""
15-
16-
pass
17-
15+
if:
16+
power_pellet_active(bool) = True and touching_ghost (bool) = True
17+
return True
18+
19+
else:
20+
return False
1821

1922
def score(touching_power_pellet, touching_dot):
2023
"""Verify that Pac-Man has scored when a power pellet or dot has been eaten.
@@ -27,8 +30,9 @@ def score(touching_power_pellet, touching_dot):
2730
bool: Has the player scored or not?
2831
2932
"""
30-
31-
pass
33+
if:
34+
touching_power_pellet(bool) = True or touching_dot(bool) = True
35+
return True
3236

3337

3438
def lose(power_pellet_active, touching_ghost):
@@ -41,8 +45,9 @@ def lose(power_pellet_active, touching_ghost):
4145
Returns:
4246
bool: Has the player lost the game?
4347
"""
44-
45-
pass
48+
if:
49+
power_pellet_active(bool) = False and touching_ghost(bool) = True
50+
return True
4651

4752

4853
def win(has_eaten_all_dots, power_pellet_active, touching_ghost):
@@ -56,5 +61,5 @@ def win(has_eaten_all_dots, power_pellet_active, touching_ghost):
5661
Returns:
5762
bool: Has the player won the game?
5863
"""
59-
60-
pass
64+
if: has_eaten_all_dot(bool) = True and power_pellet_active(bool) = True and touching_ghost = True and lose(power_pellet_active, touching_ghost) =! True
65+
return False

0 commit comments

Comments
 (0)