I have been playing chess since primary school and one day I had an idea to implement chess in Python. Then, I came across a tutorial by Eddie Sharick, who made a whole 16 episodes series covering the topic. This repository is a result of following his videos, sometimes coming up with some improvements on my own. Hereby, I highly encourage you to visit his YouTube channel and check the whole series by yourself.
First episode of "Chess engine in Python"
feel free to contribute 😀
- Cleaning up the code - right now it is really messy.
- Change move calculation to make it more efficient. Instead of recalculating all moves, start with moves from previous board and change based on last move made.
- Calculate both players moves given a position.
- Stalemate on 3 repeated moves or 50 moves without capture/pawn advancement.
- If move is a capture move, even at max depth, continue evaluating until no captures remain (not sure if this could help calculating the board score better).
- Using numpy arrays instead of 2d lists.
- Menu to select player vs player/computer.
- Allow dragging pieces.
- Flip board options (display from black perspective).
- Change color of board/pieces - different piece skins.
- Clone this repository
- Run
python3 -m pip install -r ./requirements.txt
- Run
python3 ChessMain.py
. - Enjoy the game!
- Press
z
to undo a move. - Press
r
to reset the game.
- For now, the game runs with PvP mode enabled.
- Move ordering - look at checks, captures and threats first, prioritize castling/king safety, look at pawn moves last (this will improve alpha-beta pruning). Also start with moves that previously scored higher (will also improve pruning).
- Hash board positions already visited to improve computation time for transpositions, so that after a move is made the engine doesn't have to recalculate all the moves.
- Evaluating kings placement on the board (separate in middle game and in the late game).
- Book of openings.