170 likes | 440 Views
Intelligent Pac-Man Ghost AI. CPE 480 – Fall 2008 Bill Hess Brian Mark Richard McDaniel Wesley Hamilton Evin Thompson. Objective. To create a new AI for the ghosts in the game Pac-Man. This AI must be more difficult than the original.
E N D
Intelligent Pac-Man Ghost AI CPE 480 – Fall 2008 Bill Hess Brian Mark Richard McDaniel Wesley Hamilton Evin Thompson
Objective • To create a new AI for the ghosts in the game Pac-Man. • This AI must be more difficult than the original. • It should implement several concepts from Artificial Intelligence. • The ghosts should act cooperatively.
Original AI • We modified the source for the Pac-Man game found at www.bennychow.com. • Original ghosts moved only based on best-first search • Ghosts would move to the cell with the closest absolute distance to Pac-Man. • Ghosts not allowed to go back the way they came. • Ghosts have a simple check to not follow each other down corridors. • There is a 50% chance that ghosts will take the next-best direction at intersections.
Evaluation Criteria • Percent of rounds won (by the player). • Should be as small as possible • Points won by the player. • Should be as small as possible • Time taken to complete a round to a win. • Should be as large as possible. The AI should prevent the player from winning as long as possible • Time taken to complete a round to a loss. • Should be as small as possible. The AI should defeat the player as fast as possible.
Testing Environment • We modified the game environment to include a Testing Mode • This allows testers to play alternating rounds against the original AI and the new AI with a reset round each time. • Evaluation results are recorded and displayed in a window after all testing rounds are finished
Smart AI – Uniform Cost Search • Our AI uses a uniform-cost search to find a path to Pac-Man. • Cells are all given a weight of 1 at the beginning of the traversal. • The closest ghost to Pac-Man (found by using a breadth-first search) is chosen and finds a path using the uniform-cost search. • All cells the ghost walks over has its cost increased by 2. The next closest ghost is chosen and the uniform-cost search is run again. • This search is performed each time a ghost crosses a cell
Smart AI – Uniform Cost Search • Advantages: • Ghosts can now change directions quickly if Pac-Man makes a sudden change in direction. • Ghosts can follow each other for short periods of time and split up later. • Ghosts begin to take different paths earlier in the pursuit. • Ghosts can search to the next intersection that Pac-Man is headed towards in order to predict his movements.
Smart AI – Other Behaviors • Objective Guarding • Ghosts will stand over power pellets and food pellets when there are only a few left on the map. • This forces the player to think ahead about leaving behind pellets or when to use a power pellet
Smart AI – Other Behaviors • Fleeing Behavior • All but the closest ghost will flee early if Pac-Man is near a Power Pellet. • This prevents the player from sitting next to a pellet and eating all the ghosts once they get close. • Once Pac-Man has eaten a Power Pellet, all ghosts will flee up to a certain distance based on how much time is left until the Power Pellet runs out. • This means that ghosts will resume pursuing Pac-Man before the Power Pellet times out.
Smart AI – Commander Class • Appoints tasks to all ghosts every time they cross a cell • Tasks are represented by a destination location • Tasks are appointed in order of priority • Priority of tasks • Leave room, enter room, flee • Chase Pac-Man • Defend food/Power Pellet • Back off, block intersections
Smart AI – Commander Class • Gives all ghosts a direction to move based on their task • The ghosts are only given the first step of the path to their final destination. • Ghosts must ask the Commander for the next direction each time they move to a cell. • The Commander uses uniform-cost search and breadth-first search to pick the next direction for each ghost when the ghosts request one. • BFS is used for leaving and entering the room. • UCS is used for all other tasks.
Future Improvements • Blind testing environment • Make it so the tester doesn’t know which AI is being played against. • Randomly choose the AI to be played against. • Improve fleeing • In level 1, ghosts tend to bunch together. • Make ghosts run away from each other as well as the player.
Demo http://users.csc.calpoly.edu/~whess/480/build/PacMan.htm