A python program to play chess against an AI in the terminal.
Also check out my other project, a program to practice chess tactics.
Requires Python 3, run the following to install :
pip3 install cl-chess
Run the following command after installation
chess
Type '?' to get help at any time during the game.
You'll be asked to choose between playing as white or black, and what depth you want the AI to search :
You can then make any (legal) move :
Instead of a move, you can input :
l
to see every legal mover
to make a random moveu
to undo your last move
The AI is a simple brute-force AI with no pruning. It evaluates a given position by counting the value of the pieces for each side (pawn -> 1, knight/bishop -> 3, rook -> 5, queen -> 9). It will evaluate the tree of moves, and take the path that results in the greatest gain. To learn more, check out my post on how it works.