In this exercise, you need to translate some rules from the classic game Pac-Man into Haskell functions.
You have four rules to translate, all related to the game states.
Don't worry about how the arguments are derived, just focus on combining the arguments to return the intended result.
Define the eatsGhost function that takes two arguments (whether Pac-Man has a power pellet active and Pac-Man is touching a ghost) and returns a Bool value when Pac-Man is able to eat the ghost.
The function should return True only when Pac-Man has a power pellet active and is touching a ghost.
eatsGhost False True
-- -> FalseDefine the scores function that takes two arguments (whether Pac-Man is touching a power pellet and Pac-Man is touching a dot) and returns a Bool value if Pac-Man scored.
The function should return True when Pac-Man is touching a power pellet or a dot.
scores True True
-- -> TrueDefine the loses function that takes two arguments (whether Pac-Man has a power pellet active and Pac-Man is touching a ghost) and returns a Bool value if Pac-Man loses.
The function should return True when Pac-Man is touching a ghost and does not have a power pellet active.
loses False True
-- -> TrueDefine the wins function that takes three arguments (whether Pac-Man has eaten all of the dots, Pac-Man has a power pellet active, and Pac-Man is touching a ghost) and returns a Bool value if Pac-Man wins.
The function should return True when Pac-Man has eaten all of the dots and has not lost based on the arguments defined in part 3.
wins False True False
-- -> FalseIn this exercise, you need to translate some rules from the classic game Pac-Man into Haskell functions.
You have four rules to translate, all related to the game states.
Don't worry about how the arguments are derived, just focus on combining the arguments to return the intended result.
Define the eatsGhost function that takes two arguments (whether Pac-Man has a power pellet active and Pac-Man is touching a ghost) and returns a Bool value when Pac-Man is able to eat the ghost.
The function should return True only when Pac-Man has a power pellet active and is touching a ghost.
eatsGhost False True
-- -> FalseDefine the scores function that takes two arguments (whether Pac-Man is touching a power pellet and Pac-Man is touching a dot) and returns a Bool value if Pac-Man scored.
The function should return True when Pac-Man is touching a power pellet or a dot.
scores True True
-- -> TrueDefine the loses function that takes two arguments (whether Pac-Man has a power pellet active and Pac-Man is touching a ghost) and returns a Bool value if Pac-Man loses.
The function should return True when Pac-Man is touching a ghost and does not have a power pellet active.
loses False True
-- -> TrueDefine the wins function that takes three arguments (whether Pac-Man has eaten all of the dots, Pac-Man has a power pellet active, and Pac-Man is touching a ghost) and returns a Bool value if Pac-Man wins.
The function should return True when Pac-Man has eaten all of the dots and has not lost based on the arguments defined in part 3.
wins False True False
-- -> False