PyFish is a lightweight chess game built with Python and Pygame. It provides a graphical 8×8 chessboard, chess piece artwork, turn tracking, move highlighting, and basic piece movement. PyFish is later going to have an autonomous second player.
- Graphical chessboard using Pygame
- White and black piece textures included in
images/ - Alternating turns, with White moving first
- Highlighted selectable pieces and valid destinations
- Basic movement rules for pawns, rooks, bishops, knights, and queens
- Capturing of opposing pieces
- Python 3.8+
- Pygame
pip install pygame- Clone the repository to install PyFish.
git clone https://github.com/Atticus-Beard/PyFish.git- Install the dependency:
python -m pip install -r requirements.txtFrom the project root (so the images/ folder can be found):
python main.py- White plays first.
- Click one of your pieces to select it. The square is highlighted and valid moves appear as dots.
- Click a destination square to move the piece. If the move is invalid, the selection is cleared.
- Click on the same piece again to deselect it.
- Turns alternate automatically after every valid move.
Close the window to quit the program.
.
├── main.py # The game
├── images/ # Piece textures
│ ├── wR.png wN.png wB.png wQ.png wK.png wP.png
│ └── bR.png bN.png bB.png bQ.png bK.png bP.png
└── README.md
The images/ folder must contain 12 PNG files, one per piece. Filenames are <color><piece>.png, where color is w (white) or b (black), and piece is one of:
| Code | Piece |
|---|---|
R |
Rook |
N |
Knight |
B |
Bishop |
Q |
Queen |
K |
King |
P |
Pawn |
Images are scaled automatically to fit each square (80x80 px)
- Board State is a 2d list of two-character strings, such as
"wP"for a white pawn or"--"for an empty square. is_valid_move(board, start, end)checks a move to see if it is valid against the rules for that piece.draw_boardanddraw_piecesrender the squares, highlights, move indicators, and piece sprites each frame.mainruns the event loop, handles mouse clicks, and tracks the selected piece and whose turn it is.
This is a work in progress. The following are not implemented. To view complete roadmap view issue [#7](https://github.com/Atticus-Beard/PyFish/issues/
- Castling
- En passant
- Pawn Promotion
- Game-over / win screen and reset
- Bot player
The board colors come from chess.com.
The piece images are from Wikimedia Commons and are included in the /images folder. See Wikimedia Commons for each image's license and attribution requirements.
PyFish is named after Stock Fish.