BitChess is a simple chess game written in Python using the python-chess
and pygame
libraries. It allows you to play
against any compatible chess engine.
- Play against any compatible chess engine.
- Simple and intuitive graphical interface.
- Sound effects for moves and captures.
- Game over detection (checkmate, stalemate, draw).
-
Make sure you have Python 3 installed.
-
Install the required libraries:
pip install -r requirements.txt
-
Download a compatible chess engine executable for your operating system. You can find the Stockfish executable here.
-
Place the Stockfish executable in a folder named
engine
in the same directory as the Python script. -
Change the
ENGINE_PATH
variable in themain.py
script to point to the engine executable.
-
Run the
main.py
script:python main.py
-
Click on a white piece to select it.
-
Click on a valid square to move the piece to.
-
The engine will play its move after you.
-
The game ends when there is a checkmate, stalemate or draw.
The code is organized into the following functions:
draw_chessboard()
: Draws the chessboard on the screen.draw_pieces()
: Draws the pieces on the chessboard.play_ai()
: Makes the engine play a move.display_game_over()
: Displays the game over message.update_display()
: Updates the display.main()
: The main function that runs the game loop.
This project is licensed under the MIT License. See the LICENSE file for details.
We hope you enjoy BitChess! If you'd like to contribute, feel free to open an issue or submit a pull request. Your feedback and improvements are always valued!