(Northwestern CS348 Lab #2)
Also known as Hawaiian Checkers, Konane is a strategy game played between two players. Players alternate taking turns, capturing their opponent's pieces by jumping their own pieces over them (if you're familiar with checkers, there is a strong structural analogy to be made here, except the jumping is not diagonal but orthogonal, and while multiple jumps are allowed in a turn, all jumps have to occur in the same direction). The first player to be unable to capture any of their opponent's pieces loses.
The full rules can be read here or here, and here's a nice video explaining the rules simply as well.
Here's a (rather terse) version of the rules, though:
This program implements Minimax and Alpha-Beta Pruning for an agent playing Konane. Wait, isn't Alpha-Beta Pruning a variant of Minimax? Yes, it is. It's just that here we're using Minimax and Alpha-Beta Pruning to respectively refer to Minimax WITHOUT Alpha-Beta Pruning and Minimax WITH Alpha-Beta Pruning.
Playing the game interactively may only work on Linux and Mac.
Run the following from your terminal:
python main.py $P1 $P2
By default, main.py
will setup a human player versus a random player on a board that is 10x10. During Human mode, move the cursor with the ARROW keys and select the tile with SPACE. When it is a computer's turn, advance the game with the SPACE key. To see the game board in your terminal, you need a minimum terminal size of (rows + 2) x (columns + 2) to see the whole board. To exit the game, kill the process in your terminal (e.g., with CTRL-c).
You can change the game settings by passing in values to python main.py
. You need to pass in exactly two arguments. Valid arguments are as follows:
Passing in an invalid number or type of arguments will result in the system defaulting to a human vs. a random player.
On the codebase:
player.py
— contains MinimaxPlayer
and AlphaBetaPlayer
main.py
—to play the game (in Human mode) or to watch your agents duke it out, run python main.py
. Use the arrow
keys and the spacebar to select your actions.test.py
—run tests with python test.py
.game_manager.py
—holds the board representation and handles turn-taking.game_rules.py
—code determining available moves, their legality, etc.main.py