C++ Console Chess Game This is a simple, text-based two-player chess game written in C++. It is designed to run in the console and serves as a practical demonstration of fundamental Object-Oriented Programming (OOP) principles.
Features Complete Piece Set: All standard chess pieces (Pawn, Rook, Knight, Bishop, Queen, King) are implemented.
Playable Game Loop: Supports a full two-player game with alternating turns for White and Black.
Text-Based Board: The game state is displayed as a clear, text-based board in the console after every move.
Chess Notation Input: Players make moves using standard algebraic notation (e.g., e2 e4).
How to Compile and Run This project is written in standard C++ and can be compiled with any modern C++ compiler, such as g++.
Navigate to the Directory: Open your terminal or command prompt and navigate to the directory where you saved the .cpp file.
Compile the Code: Use the following command to compile the program. This will create an executable file named chess.
g++ your_file_name.cpp -o chess
Run the Game: Execute the compiled program to start the game.
./chess
How to Play The game will display the board and prompt the current player for their move.
Moves must be entered in algebraic notation with a space in between the start and end squares.
The format is [start_square] [end_square]. For example: e2 e4.
The game is case-insensitive, so e2 e4 and E2 E4 are both valid.
To end the game, type quit when prompted for a move.
Object-Oriented Design This project was built to demonstrate key OOP concepts:
Inheritance: A base Pieces class defines a common interface for all pieces. Specific classes like Pawn, Rook, and Queen inherit from Pieces, creating a clear "is-a" relationship.
Polymorphism: The use of virtual functions like isValidMove() and getSymbol() allows the Board class to treat all pieces generically. When piece->getSymbol() is called, the program correctly determines at runtime which specific piece's symbol to display.
Abstraction: The Pieces class abstracts away the complex movement logic of each piece. The Board does not need to know how a Knight moves, only that it can ask the Knight if a move is valid.
Encapsulation: The game state (the pieces grid and currentPlayer) is kept private within the Board class. All interactions are handled through public methods (movePieces(), printBoard(), StartGame()), protecting the internal data from unintended access.
Known Issues & Future Improvements This is a foundational version of the game with several key features yet to be implemented.
Path Blocking: Rooks, Bishops, and Queens can currently jump over other pieces. The move validation needs to be enhanced to check for blocked paths.
Incomplete Pawn Logic: Pawn move validation does not yet handle diagonal captures or en passant.
No Check/Checkmate Logic: The game does not currently detect if a King is in check, nor does it have conditions for checkmate or stalemate.
No Special Moves: Castling and pawn promotion have not been implemented.