This game requires additional Python libraries. Install them using pip
command.
pip install -r requirements.txt
To speed up best move search CMiniMax algorithm has been written in C++. Build them by using following command.
python setup.py build
Read more about using C++ in Python code here.
Use server
argument to start the server. By running following command
server will listen for connections on 127.0.0.1:20202
with turn timeout of 60
seconds.
python -m kalaha server -H 127.0.0.1 -p 20202 -tt 60
Update environment variables in docker-compose.yml
file and spin up containers.
docker-compose up
Start client and connect with server IP address and port autofilled.
python -m kalaha client -H 127.0.0.1 -p 20202
Auto player can be configured via in-game GUI or command arguments. Note: You will not be able to make moves manually.
Start client, connect to server and enable autoplay.
This command configures minimax algorithm to search for best move in tree of depth 4
.
Delay of auto move will be 5
seconds.
python -m kalaha client -ap -apd 5 -md 4
You can enable alpha-beta pruning by passing -ab
argument.
python -m kalaha client -ap -apd 5 -md 4 -ab
You can enable iterative deepening by passing -id
argument.
python -m kalaha client -ap -apd 5 -md 4 -id
To enable move highlighting, pass -hm
argument.
python -m kalaha client -hm -md 4
Human vs. Human, Human vs. Auto player, Auto player vs. Auto player.
Every move including pit selection is validated on the server side.
Autoplayer uses minimax algorithm to find the best move. Optimalizations were made to improve the performance and win rate.
- iterative deepening
- alpha-beta pruning
- tree is generated level by level when minimax traverses the tree
- auto player is written in C++
Important: Algorithm is run on client side. It is running in separate thread,
but setting high tree depth can cause the client to freeze and exceed the player's time limit.
Recommended tree depth is 4
.
- qtpy - abstraction layer for PyQt5/PySide2
- PyQt5 - Qt5 bindings for Python
- qrainbowstyle - custom windows and widgets style
- QtPyNetwork - high level network library
- coloredlogs - colored logging