This repository contains a skeleton implementation of a Chess AI engine written in C++. The project is designed to teach fundamental concepts of game AI, including board representation, move generation, and basic game tree search algorithms.
This project serves as a teaching tool for computer science students to understand:
- Game state representation
- Object-oriented design in C++
- Basic AI concepts in game playing
- Bitboard operations and chess piece movement
- FEN (ForsythβEdwards Notation) for chess position representation
-
Chess Class: Core game logic implementation
- Board state management
- Move validation
- Game state evaluation
- AI player implementation
-
Piece Representation
- Unique identifiers for each piece type
- Sprite loading and rendering
- Movement pattern definitions
-
Board Management
- 8x8 grid representation
- Piece positioning
- Move history tracking
- FEN notation support
- C++ compiler with C++11 support or higher
- Image loading library for piece sprites
- CMake 3.10 or higher
mkdir build
cd build
cmake ..
make
./chess_tests
- Basic board setup and initialization
- Piece movement validation framework
- FEN notation parsing and generation
- Sprite loading for chess pieces
- Player turn management
- AI move generation
- Position evaluation
- Opening book integration
- Advanced search algorithms
- Game state persistence
bool Chess::canBitMoveFromTo(Bit& bit, BitHolder& src, BitHolder& dst) {
// TODO: Implement piece-specific movement rules
return false;
}
const char Chess::bitToPieceNotation(int row, int column) const {
if (row < 0 || row >= 8 || column < 0 || column >= 8) {
return '0';
}
// Implementation details for FEN notation
}
- Implement piece placement
- Setup initial board state
- Validate board representation
- Implement basic piece movements
- Add move validation
- Implement special moves (castling, en passant)
- Develop position evaluation
- Implement minimax algorithm
- Add alpha-beta pruning
- Basic opening book
Students are encouraged to:
- Fork the repository
- Create a feature branch
- Implement assigned components
- Submit their fork for review
- Use consistent indentation (4 spaces)
- Follow C++ naming conventions
- Document all public methods
- Include unit tests for new features
This project is licensed under the MIT License.
- [Your Name] - Initial work
- [Student Names] - Implementation and testing
Moves generator takes 0 arguments and is called when the player clicks on a piece and moves to another spot
King moves are generated after calling a kingMoveGenerator() that searches for all the moves from enemy player that puts the current king in danger
Castling added by adding new booleans to bits to see if they have moved yet. If the king hovers over and open rook, then spawn new piece and delete the old piece
EnPassant added by adding new bit holders and booleans in chess.h. It checks which direction the enpassant is going, and if the pawn that is being eaten had just last moved and did a 2 move jump
Helped functions added: findKingPosition(), isMoveLegal(), negaMax(), canMoveBlockAttack(), canBlockAttack(), getBestMove(), kingChecked(), and simulateMove()
getBestMove() calls negaMax(), and which generates all possible moves for that player with the current board state and filters through legal moves with isMoveLegal().
The move is simulated with simulateMove() and isMoveLegal() goes through all possible moves, and if the king is in check, then we search for moves that can block/protect the king with canBlockAttack() and canMoveBlockAttack(), if there are no moves then it is checkmate.
This README is part of an educational project and is intended to serve as an example of good documentation practices.