This project is a simplified chess game implemented in Python. It allows two players to compete against each other by following the core rules of chess, with a few exceptions for simplicity. The focus is on piece movement, capturing the king, and turn-based gameplay rather than the full complexity of check and checkmate.
- User registration and login system
- Ability to start a new game with another registered user
- Pieces move according to the standard chess rules (except castling, en passant, and pawn promotion)
- Simple board display in text format
- Option to select and deselect pieces
- Undo functionality (each player can undo up to two moves per game)
- Configurable move limit (or unlimited if set to 0)
- Forfeit option if a player wants to give up
Clone the repository and move into the project directory:
git clone https://github.com/soroushsohrabi/Chess.git
cd ChessThis project only relies on Python's standard library. No external dependencies are required.
Make sure you are running Python 3.8 or later.
Run the game with:
python Chess.pyThe game is entirely command-driven. Here are the main commands:
register [username] [password]→ create a new accountlogin [username] [password]→ log in with your accountnew_game [username] [limit]→ start a game with another user, limit = number of moves allowed (0 = unlimited)select [x],[y]→ select a piece at given coordinatesmove [x],[y]→ move the selected piece to a new spotnext_turn→ finish your move and pass the turn to the opponentundo→ revert your last move (max 2 per player)show_board→ print the current board stateforfeit→ give up the gamelogout→ log out of your accountexit→ close the program
- The game ends when a king is captured.
- Check and checkmate are not part of this version.
- Pawn rules: can move one or two squares forward on their first move, afterwards only one. Capturing is diagonal.
- Bishop moves diagonally, rook moves horizontally/vertically, queen moves like both, knight moves in an "L" shape and can jump over pieces, king moves one square in any direction.
- No castling, no en passant, and no pawn promotion.
- If the move limit (set at game start) is reached, the game ends in a draw.