An open API service indexing awesome lists of open source software.

https://github.com/pd-mera/game-of-nim

Master the Minimax Algorithm and Alpha-Beta Pruning with Game of Nim
https://github.com/pd-mera/game-of-nim

alpha-beta-pruning game game-ai minimax-algorithm

Last synced: 3 months ago
JSON representation

Master the Minimax Algorithm and Alpha-Beta Pruning with Game of Nim

Awesome Lists containing this project

README

        

# Master Minimax Algorithm with Game of Nim

![](./assets/minimax_nim_tree.png)

## How to run

Just specify game you want to play and run

``` bash
python console.py -g simple
# python console.py -g regular --first Human
# python console.py -g misere --second Human
# python console.py -g split --first Human --second Human
```

## Some example games

- Simple Nim

![](./assets/simple.png)

- Regular Nim

![](./assets/regular.png)

## New knowledges learned from this projects

- How to use recursive to implement minimax algorithm
- Principle about minimax algorithm
- ~~Using `@cache` to cache minimax state~~ (Support in python > 3.9)
> Instead using `@lru_cache(maxsize=None)`
- How to use Alpha-Beta Pruning

## TODO

- [ ] Implement more variants

## Reference

- [Minimax in Python: Learn How to Lose the Game of Nim](https://realpython.com/python-minimax-nim/)