Pacman vs Ghosts PLAYING THE GAME Introduction Daryl

  • Slides: 37
Download presentation
Pacman vs Ghosts PLAYING THE GAME

Pacman vs Ghosts PLAYING THE GAME

Introduction - Daryl Tose Keen game player from childhood BSc Mathematics and Computer Science

Introduction - Daryl Tose Keen game player from childhood BSc Mathematics and Computer Science Magic The Gathering AI competitions Winner of the CIG 2011 competition Top 10 in the Google AI challenge 2011

Content History The Pac. Man vs Ghosts competition Approaches and evolution Systems thinking and

Content History The Pac. Man vs Ghosts competition Approaches and evolution Systems thinking and the Metagame Learning

Learning styles Visual Aural Kinaesthetic

Learning styles Visual Aural Kinaesthetic

History Pac. Man Launched in 1980 Ms Pac. Man 1982 The most successful arcade

History Pac. Man Launched in 1980 Ms Pac. Man 1982 The most successful arcade machine of all time AI competitions run from 2007 Pac. Man vs Ghosts from 2011

How the game works Pac. Man controlled by the human player using a joystick

How the game works Pac. Man controlled by the human player using a joystick 4 AI controlled ghosts 4 Different Mazes 220 scoring pills 4 power pills Wrap around tunnels Random scoring fruit

Aim of the game Avoid being caught by the ghosts Clear the level of

Aim of the game Avoid being caught by the ghosts Clear the level of pills to advance to the next level Score as many points as possible Pill – 10 points Power pill – 50 points Edible ghost – 200, 400, 800, 1600

Content History The Pac. Man vs Ghosts competition Approaches and evolution Systems thinking and

Content History The Pac. Man vs Ghosts competition Approaches and evolution Systems thinking and the Metagame Learning

The competition Can compete as the Pac. Man or as the Ghosts Game engine

The competition Can compete as the Pac. Man or as the Ghosts Game engine Written in Java Provides full game state knowledge Package contains Starter. Pacman and Starter. Ghost examples Each game tick you have 40 ms to return your move(s)

Changes from the original No fruit Random ghost reversals (1 in 650 chance) Ghosts

Changes from the original No fruit Random ghost reversals (1 in 650 chance) Ghosts controlled by opponents Maximum of 16 levels Level time limit of 3000 ticks (2 minutes) Points for remaining pills are awarded to Pac. Man

Competition Format Round-robin All Pacman bots play against all Ghost bots Averaged score over

Competition Format Round-robin All Pacman bots play against all Ghost bots Averaged score over 5 games Reduces luck (random reversals) All game replays available for review Allows human learning Download for AI learning

Aims Ghosts: minimize the Pac. Man’s score Trap the Pac. Man Avoid being eaten

Aims Ghosts: minimize the Pac. Man’s score Trap the Pac. Man Avoid being eaten while edible Pac. Man: maximize the Pac. Man’s score Make the most of the power pills (3, 000 points if you can eat all 4 ghosts) Avoid being caught

Content History The Pac. Man vs Ghosts competition Approaches and evolution Systems thinking and

Content History The Pac. Man vs Ghosts competition Approaches and evolution Systems thinking and the Metagame Learning

Approaches Rule based High domain knowledge ~40 Junctions, 60 Paths, 1500 nodes Mini. Max

Approaches Rule based High domain knowledge ~40 Junctions, 60 Paths, 1500 nodes Mini. Max Limited domain knowledge (score) 10, 000 game states (depth 12) With domain knowledge (heuristics) Monte. Carlo Minimal domain knowledge ~3 play outs

Evolution Pac. Man score per level 14000 12000 10000 8000 6000 4000 2000 0

Evolution Pac. Man score per level 14000 12000 10000 8000 6000 4000 2000 0 Phantom Spooks II Monte. Carlo Mini. Max Spooks III

Phantom Menace Ghosts that work as a team Rule based Map the maze onto

Phantom Menace Ghosts that work as a team Rule based Map the maze onto points of interest Junctions Paths Power Pills Edible Ghosts

Path and Junction analysis Map game state onto a graph (junctions and paths, direction

Path and Junction analysis Map game state onto a graph (junctions and paths, direction is important) Work out time taken for each ghost to block each path Work out the distance and arrival direction for the Pac. Man to get to each junction Mark paths as blocked or not

Phantom Menace – Taxi pickup Each is a taxi The junction at the start

Phantom Menace – Taxi pickup Each is a taxi The junction at the start of each path that can be blocked is a pickup request The aim Find the best assignment of taxis to pickups such that we pickup as many people as possible using the least amount of petrol

Algorithm Brute force with pruning Loop through all possible pickup options Prune options that

Algorithm Brute force with pruning Loop through all possible pickup options Prune options that have duplicate pickups Record total distance travelled by all taxis Pick the option using the least petrol

Phantom Menace - Results Ghosts 1. 3, 917 xsl 11 2. 4, 308 jackhftang

Phantom Menace - Results Ghosts 1. 3, 917 xsl 11 2. 4, 308 jackhftang 3. 4, 384 Phantom. Menace Pac. Man rarely made it passed the first level The performance against the top Pac. Man bots essentially determined the final placings. Random reversals had a big impact on the scores

Phantom Menace - Pac. Man Use blocking knowledge to pick path least likely to

Phantom Menace - Pac. Man Use blocking knowledge to pick path least likely to be blocked Use number of blocking points as an indicator of how much danger Pac. Man is in If safe – eat nearest pill If not – head to best escape route Only eat power pills if Trapped All ghosts are in edible range Near the end of the level time limit

Algorithm Score each point of interest in the maze Pick the highest scoring point

Algorithm Score each point of interest in the maze Pick the highest scoring point Work out route to this point Hover next to power pill until forced to eat it Major bug found in escape route logic

Spooks – catch me if you can Analyse nodes, not paths Always head to

Spooks – catch me if you can Analyse nodes, not paths Always head to best escape node No pill eating logic Power pills treated as walls (dead ends) Same edible ghost logic

Spooks – Node analysis Accessible Zone Event Horizon The places a ghost and Pac.

Spooks – Node analysis Accessible Zone Event Horizon The places a ghost and Pac. Man would meet Lines Shortest route to event horizon

Event Horizon Uses a recursive “flood” algorithm to cache all distances and arrival directions

Event Horizon Uses a recursive “flood” algorithm to cache all distances and arrival directions from all nodes to all other nodes. Run once, during first game tick. Takes 2 -3 seconds to complete Cached data used to determine event horizon on subsequent game ticks

CIG 2011 - Results Pacman 1. 41, 447 Spooks 2. 32, 108 Phantom. Menace

CIG 2011 - Results Pacman 1. 41, 447 Spooks 2. 32, 108 Phantom. Menace 3. 20, 009 ICEp. Ambush Ghosts 1. 3, 917 xsl 11 2. 4, 308 jackhftang 3. 4, 384 Phantom. Menace Phantom Menace Assumes best play by the ghosts Reduces game state to points of interest Tries to clear each level Spooks Assumes weak play by the ghosts Analyses each node Tries to escape (no longer playing the original game)

Content History The Pac. Man vs Ghosts competition Approaches and evolution Systems thinking and

Content History The Pac. Man vs Ghosts competition Approaches and evolution Systems thinking and the Metagame Learning

Systems Thinking Strategy (Algorithms) Scoring system Opponents and the Metagame

Systems Thinking Strategy (Algorithms) Scoring system Opponents and the Metagame

WCCI June 2012 Changes to the rules Maximum 8 levels (not 16) Half points

WCCI June 2012 Changes to the rules Maximum 8 levels (not 16) Half points for remaining pills Changes to the metagame Spooks code had been published More entrants

Spooks - Ghosts I needed a better ghost team to test against Try to

Spooks - Ghosts I needed a better ghost team to test against Try to minimise area of the maze that Pac. Man has access to Maximise dispersal of ghosts when edible Moves rated on heuristics (scored after moves applied) Safe area Access to power pill Access to pills Distance of edible ghost nearest to Pac. Man to nearest edible ghost

Algorithm Breadth first search Simultaneously expand from all ghosts and from the Pac. Man,

Algorithm Breadth first search Simultaneously expand from all ghosts and from the Pac. Man, stopping when they meet Take into account time in the lair and speed reduction when edible Execution time < 3 ms Fast enough to fully analyse each combination of ghost moves (1 move look ahead)

Refinements to Spooks Pac. Man Maximise score against weaker opponents Exploit weaknesses of Starter

Refinements to Spooks Pac. Man Maximise score against weaker opponents Exploit weaknesses of Starter Ghosts Maximise power pills Timing Luring Travelling Salesman

Summary Pac. Man score per level 14000 12000 10000 8000 6000 4000 2000 0

Summary Pac. Man score per level 14000 12000 10000 8000 6000 4000 2000 0 Phantom Spooks II Monte. Carlo Mini. Max Spooks III

Content History The Pac. Man vs Ghosts competition Approaches and evolution Systems thinking and

Content History The Pac. Man vs Ghosts competition Approaches and evolution Systems thinking and the Metagame Learning

Learning Keep it simple Share your ideas Keep an eye on the big picture

Learning Keep it simple Share your ideas Keep an eye on the big picture Work with the system you have Contribute to continuous improvement

And finally. .

And finally. .

And finally. . 80% of all pie charts will now start to look like

And finally. . 80% of all pie charts will now start to look like Pac. Man Others