Skip to content

Thomas-YIN/Pacman-with-perceptrons-and-state-machines

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 

Repository files navigation

Boundary-following Pacman with perceptrons and state machines

Project description

This is a simple exercise to implement the boundary following production systems in the Pacman game from UC Berkeley. The goal of the Pacman game is simple: control the Pacman to eat all the foods in the map, as shown below.

pacman game

Different types of agents

  • NaiveAgent: The agent goes west until it cannot.
  • PSAgent: The agent moves according to a pre-defined production system.
  • ECAgent: The agent moves according to a perceptron trained using the error-correction method.
  • SMAgent: The agent is a state machine with impaired sensors and moves according to a production system based on previous and current senses, as well as the previous move.

ECAgent

The ECAgent's action is determined by a single layer perceptron trained on the four training sets named north.csv, east.csv, south.csv, and west.csv. Each file stores the environment states when moving north, east, south, and west. Each vector in the training set is in the form of $(s_1,...,s_8,d)$, where the first $8$ elements are the Pacman’s sensor readings, and $d$ is the label of this input, with $d = 1$ meaning a positive, and $0$ a negative example.

SMAgent

The SMAgent is sensory-impaired and can only received only 4 sensor inputs from the 4 directions: north, east, south, west. The agent receives sensor values from the getPacmanImpairedSensor function. The sensory input $(s_2, s_4, s_6, s_8)$ corresponds to the sensor values from the north, east, south, and west respectively. The SMAgent can remember the previous action prevAction and the previous sensory input prevSense. The agent moves according to a production system based on previous and current senses, as well as the previous move.

How to run the game

Run python pacman.py --layout testMap --pacman NaiveAgent to how the NaiveAgent acts. Note that the --layout parameter specifies the map, and the --pacman parameter specifies the agent.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages