https://github.com/jdsherbert/chess
A simple command-line chess game implemented in C++. It allows you to play against an AI player using basic chess rules.
https://github.com/jdsherbert/chess
chess cplusplus cpp minmax-algorithm
Last synced: 2 months ago
JSON representation
A simple command-line chess game implemented in C++. It allows you to play against an AI player using basic chess rules.
- Host: GitHub
- URL: https://github.com/jdsherbert/chess
- Owner: JDSherbert
- License: mit
- Created: 2023-07-14T19:15:55.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-11-05T15:11:45.000Z (over 1 year ago)
- Last Synced: 2025-02-13T22:38:17.757Z (4 months ago)
- Topics: chess, cplusplus, cpp, minmax-algorithm
- Language: C++
- Homepage: https://linktr.ee/JDSherbert
- Size: 26.4 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README

# Chess
![]()
![]()
![]()
![]()
![]()
![]()
-----------------------------------------------------------------------
![]()
![]()
-----------------------------------------------------------------------
This is a simple command-line chess game implemented in C++. It allows you to play against an AI player using basic chess rules.## Features
- Human vs AI gameplay
- Basic chess piece movements (pawn, knight, bishop, rook, queen, king)
- Valid move checking
- Alpha-beta pruning for AI player using the Minimax algorithm
- Evaluation function to assess the board position## Getting Started
To compile and run the game, you'll need a C++ compiler installed on your system. Follow these steps:
1. Clone the repository to your local machine:
```shell
git clone https://github.com/JDSherbert/Chess.git
```
Navigate to the project directory:```shell
cd Chess
```
Compile the code (exact method will depend on your compiler):```shell
g++ -std=c++11 Chess.cpp -o Chess
```
Run the game:```shell
./chess
```
Follow the on-screen instructions to play the game.## How to Play
The chessboard is displayed as an 8x8 grid.
The black pieces are represented by Unicode symbols.
The white pieces are represented by uppercase letters.
Moves are entered in the format "from_square to_square" (e.g., "e2 e4" to move a pawn from e2 to e4).
The game alternates between the human player and the AI player.
The AI player uses the Minimax algorithm with alpha-beta pruning to make its moves.### Example Gameplay
```mathematica
A B C D E F G H
1 ♜ ♞ ♝ ♛ ♚ ♝ ♞ ♜
2 ♟ ♟ ♟ ♟ ♟ ♟ ♟ ♟
3
4
5
6
7 ♙ ♙ ♙ ♙ ♙ ♙ ♙ ♙
8 ♖ ♘ ♗ ♕ ♔ ♗ ♘ ♖Enter your move (e.g., 'e2 to e4'): e2 e4
A B C D E F G H
1 ♜ ♞ ♝ ♛ ♚ ♝ ♞ ♜
2 ♟ ♟ ♟ ♟ ♟ ♟ ♟
3
4 ♟
5
6
7 ♙ ♙ ♙ ♙ ♙ ♙ ♙ ♙
8 ♖ ♘ ♗ ♕ ♔ ♗ ♘ ♖AI moved: g8 f6
A B C D E F G H
1 ♜ ♞ ♝ ♛ ♚ ♝ ♞ ♜
2 ♟ ♟ ♟ ♟ ♟ ♟ ♟
3
4 ♟
5
6 ♘
7 ♙ ♙ ♙ ♙ ♙ ♙ ♙ ♙
8 ♖ ♘ ♗ ♕ ♔ ♗ ♖
```