Skip to content

A two-player chess game built in Python using OOP principles, featuring a command-line interface with move history, undo support, and customizable game limits.

License

Notifications You must be signed in to change notification settings

soroushsohrabi/Chess

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Chess

Overview

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.

Features

  • 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

Installation

Clone the repository and move into the project directory:

git clone https://github.com/soroushsohrabi/Chess.git
cd Chess

This 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.py

How to Play

The game is entirely command-driven. Here are the main commands:

  • register [username] [password] → create a new account
  • login [username] [password] → log in with your account
  • new_game [username] [limit] → start a game with another user, limit = number of moves allowed (0 = unlimited)
  • select [x],[y] → select a piece at given coordinates
  • move [x],[y] → move the selected piece to a new spot
  • next_turn → finish your move and pass the turn to the opponent
  • undo → revert your last move (max 2 per player)
  • show_board → print the current board state
  • forfeit → give up the game
  • logout → log out of your account
  • exit → close the program

Game Rules

  • 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.

About

A two-player chess game built in Python using OOP principles, featuring a command-line interface with move history, undo support, and customizable game limits.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages