Coder Social home page Coder Social logo

travisddavies / pacman_adversarial_search_algorithms Goto Github PK

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

Various search algorithms in Pacman for finding optimal moves when dealing with adversarial agents, mainly minimax (including alpha beta pruning) and expectimax

Python 100.00%

pacman_adversarial_search_algorithms's Introduction

pacman_adversarial_search_algorithms

Various search algorithms in Pacman for finding optimal moves when dealing with adversarial agents, mainly minimax (including alpha beta pruning) and expectimax

All the code has been provided by UC Berkeley, apart from the search algorithms and some evaluation functions.

Reflex Agent

To play with the reflex agent, which uses A* Star Search in the evaluation function to pick the best action at the given moment, you can use the following commands:

python pacman.py -p ReflexAgent -l testClassic
python pacman.py --frameTime 0 -p ReflexAgent -k 1
python pacman.py --frameTime 0 -p ReflexAgent -k 2

Minimax

To play with the agent that uses the minimax algorithm, which makes a move based on the worst possible outcome from adversarial agents, you can use the following commands:

python autograder.py -q q2
python pacman.py -p MinimaxAgent -l minimaxClassic -a depth=4
python pacman.py -p MinimaxAgent -l trappedClassic -a depth=3
python pacman.py -p MinimaxAgent -l mediumClassic -a depth=4
python pacman.py -p MinimaxAgent -l openClassic -a depth=4

Minimax with Alpha-Beta Pruning

to play with the agent that uses the minimax algorithm, but with a more efficient time complexity since the decision tree has been pruned due to alpha and beta cut-off limits, you can use the following commands:

python pacman.py -p AlphaBetaAgent -a depth=3 -l smallClassic
python pacman.py -p AlphaBetaAgent -a depth=3 -l minimaxClassic
python pacman.py -p AlphaBetaAgent -l mediumClassic -a depth=4
python pacman.py -p AlphaBetaAgent -l openClassic -a depth=4
python autograder.py -q q3

Expectimax

To play with the agent that uses the expectimax algorithm, which relies on probability of certain consequences occuring and thus introducing some randomness to moves, you can use the following commands:

python autograder.py -q q4
python pacman.py -p ExpectimaxAgent -l minimaxClassic -a depth=3
python pacman.py -p ExpectimaxAgent -a depth=3 -l smallClassic
python pacman.py -p ExpectimaxAgent -l mediumClassic -a depth=4
python pacman.py -p ExpectimaxAgent -l openClassic -a depth=4

You can also compare the difference in outcomes with the minimax algorithm and expectimax algorithm in a futile situation like trappedClassic:

python pacman.py -p ExpectimaxAgent -l trappedClassic -a depth=3 -q -n 10
python pacman.py -p AlphaBetaAgent -l trappedClassic -a depth=3 -q -n 10

You should find that due to going off probability rather than looking at the worst outcome, expectimax can sometimes win while minimax never wins.

Evaluation Function

To play with an evaluation function that I created for various states in the game to make decisions, you can use the following commands:

python autograder.py -q q5

pacman_adversarial_search_algorithms's People

Contributors

travisddavies 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.