GithubHelp home page GithubHelp logo

simon-gardier / pacman-ai-from-scratch Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 168 KB

🕹ī¸ Basic AI algorithms from scratch for Pacman game

Home Page: https://github.com/glouppe/info8006-introduction-to-ai/tree/master/projects

Python 100.00%
bayes-filter conda python3 info8006 game pacman cs188

pacman-ai-from-scratch's Introduction

🕹ī¸ Basic AI algorithms for Pacman game

Release Language

bayes filter

Project undertaken as part of the INFO8006 course given by Pr. Louppe.
Grades :

  • Project 1 - A* : 16/20
  • Project 2 - Minimax and h-minimax : 19/20
  • Project 3 - Bayes filter : 20/20

Note : No copying (even partial) of this code within the scope of the INFO8006 course will be tolerated.

Summary

  1. Installation
  2. Project 1 - A*
  3. Project 2 - Minimax
  4. Project 3 - Bayes filter
  5. Credits

Installation

This section is taken from the project page of the INFO8006 course.

  • Install conda
  • Create a conda environment to run the programs, activate it and install NumPy
conda create --name pacman python=3.8
conda activate pacman
conda install numpy
  • Clone the repository
git clone [email protected]:sgardier/pacman-ai-from-scratch.git

Project 1

astar algorithm
The first project involves developing a pathfinding algorithm to eat all the dots while minimizing the total distance traveled.

BFS solution

This solution makes use of Breadth-First search to find the direction to the nearest dot.

Run it (from the projet-1 folder) :

python run.py --agent bfs --layout medium

Multiple layout are available : small, medium, large

A* solution

This solution make use of A* to find the direction to the nearest dot which minimizes the heuristic.
In our solution the heuristic to compute the forward cost is the Manhattan distance between the position of Pacman in the state and the farthest food dot from this position.

Run it (from the projet-1 folder) :

python run.py --agent astar --layout medium

Multiple layout are available : small, medium, large

Project 2

Minimax
The second project involves developing a algorithm which maximizes the score value.
Eating the food, eating a ghost and winning the map give points (+10, +5, +500) while walking, eating the capsules and losing the game take away points (-1, -5, -500).

Minimax

This solution is a direct implementation of minimax.

Run it (from the projet-2 folder) :

python run.py --agent minimax --ghost dumby --layout small_adv

Since Minimax is a computationally intensive algorithm, we recommend trying only the small layout.
Multiple ghost behaviors are available : dumby, greedy, smarty

H-Minimax

This solution is a variant of minimax called h-minimax.
H-minimax reduces the required computation to find a solution by adding a maximum recursion count and an heuristic.
When the maximum recursion is reached, the score given to the action =
score at recursion state reached - shotest path to all remaining foods at recursion state reached - exp(number of previous walkthrough at the position in the recursion state)

Run it (from the projet-2 folder) :

python run.py --agent minimax --ghost dumby --layout small_adv

Multiple ghost behaviors are available : small_adv, medium_adv, large_adv

Project 3

Bayes filter

The third project involves implementing a Bayes filter over noisy reading of the ghost positions.
Here the goal of pacman is to eat all the ghosts in a minimum number steps while having only access to a noisy manhattan distance to each remaining ghost.

Run it (from the projet-3 folder) :

python run.py --ghost afraid --nghosts 1 --layout large_filter --seed 19

Credits

  • Simon Gardier (Co-author)
  • Jamaa Jair (Co-author)
  • Dario Rinallo (Co-author)

pacman-ai-from-scratch's People

Contributors

simon-gardier avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤ī¸ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.