This project is a text-based Chess Game developed in C++ using Object-Oriented Programming (OOP) concepts. It provides a classic two-player chess experience with a focus on implementing the core rules and logic of the game through a clean, console-based interface.
- Two-player gameplay on a standard 8x8 board 🧑🤝🧑
- Move validation according to chess rules for each piece type (Pawn, Rook, Knight, Bishop, Queen, King) ✅
- Turn-based system to alternate between players 🔄
- Detection of check and checkmate conditions 👑
- Display of the chessboard in the console 📊
- Well-structured OOP design using classes for each component (Board, Piece, Player, etc.) 🏗️
- C++ programming language
- Object-Oriented Programming principles (Encapsulation, Inheritance, Polymorphism)
- Standard Template Library (STL) for efficient data handling
- A C++ compiler (GCC, MinGW, or any modern C++ compiler)
- Compatible with Windows, Linux, and macOS terminals
git clone https://github.com/alphaxt/Chess-game.git
Using make:
make
Or using CMake:
cmake -B build -S .
cmake --build build
Or directly with g++:
g++ -std=c++17 -Iinclude -o ChessGame src/*.cpp
./ChessGame
Chess-game/
├── include/ # Header files (.h)
├── src/ # Source files (.cpp)
├── Makefile # Build via `make`
├── CMakeLists.txt # Build via CMake
└── README.md
main.cpp— Contains the program’s entry point and the main game loop.Board.h/Board.cpp— Manages the chessboard state and display.Piece.h/Piece.cpp— Serves as the base class for all chess pieces, handling common attributes.- Individual piece classes (
Pawn,Knight,Bishop,Rook,Queen,King) — Inherit fromPieceand implement specific move validation logic. Game.h/Game.cpp— Manages the turn-based game loop and player turns.
- Upon launch, the game initializes a standard chessboard with all pieces in their starting positions.
- The game alternates between Player 1 (White) and Player 2 (Black) turns.
- Each player enters their desired move (e.g.,
e2e4). - The system validates the move to ensure it adheres to the rules of chess for the selected piece.
- If the move is valid, the board is updated, and the game checks for check or checkmate conditions.
- The game continues until a checkmate, stalemate, or draw occurs.
- Implementation of castling, en passant, and pawn promotion rules
- Addition of a simple AI opponent
- Development of a Graphical User Interface (GUI) for a better user experience
- Implementation of a game history or log to track all moves
Contributions are highly appreciated! Please feel free to open issues for bugs or feature requests, or submit pull requests to improve the project.
This project is licensed under the MIT License.
Developed by Muhammad Danish