Giter VIP home page Giter VIP logo

minimaxtextgames's Introduction

MinimaxTextGames

Text based games with numerous strategies including recursive and iterative minimax.
Based off of a CSC148 Assignment at UofT.

To play, run game_interface.py

How It Works

Overall Structure

The game_interface.py file relies on the generic Game and State classes in game.py and state.py, respectively. Therefore any game that can be made by subclassing these two classes can be played by game_interface.py. The games that can do this are generally two-player, sequential move, zero-sum, perfect-information games.

If you do make your own game using these subclasses, make sure to add the Game class to the playable_games dictionary on line 11 of game_interface.py.

Minimax

All the minimax strategies work by checking all possible moves from the current state, and picking a move that results in the highest possible 'score', or a move where if both players play perfectly, the current player will win. If this is not possible it picks a move where a tie results, or a loss as a last resort.

Recursive/Iterative

Both the recursive and iterative minimax strategies work by, either recursively or iteratively, looking through all possible moves and picking a move.

Since it does look through ALL possible moves, it can take a long time to run; for example, running minimax on a new Stonehenge Game of board size 3 can take over 4 hours to run.

Memoization

Memoization is similar to the recursive minimax strategy, however at each step of minimax, once a state's highest possible score has been found it gets added to a dictionary. Therefore, whenever we encounter a similiar state we already have it's score and don't have to do a recursive call on it.

This is one method of optimizing the recursive strategy to run faster/more efficiently.

Myopia

Myopia is also similar to the recursive minimax strategy, however it limits the depth of recursion to 4. Once depth 4 is reached, it determines a 'best_guess' using a state's rough_outcome() strategy of whether we think the state will result in a win, tie, or loss.

This method sacrifices accuracy for speed.

minimaxtextgames's People

Contributors

manveerxyz avatar

Watchers

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