Chess3001 is a full-stack chess application consisting of a powerful UCI chess engine written in C++, a Ruby Sinatra REST API, and a React frontend. The engine uses advanced chess programming principles and optimizations inspired by Stockfish.
The project is organized into three main components:
- Engine: A high-performance C++ chess engine with UCI protocol support
- Backend: A Ruby Sinatra REST API that interfaces with the engine
- Frontend: A React-based web interface for playing against the engine
The core of Chess3001 is a powerful chess engine written in C++ that implements various advanced chess programming techniques.
- Bitboards for efficient board representation
- Magic Bitboards for fast sliding piece move generation
- Principal Variation Search algorithm for finding the best moves
- Quiescence Search to optimize the search algorithm
- Move ordering to enhance alpha-beta pruning efficiency
- Linear static evaluation of pieces
- UCI protocol for GUI communication
- Improved move generation time
- Complete UCI command implementation
- Additional C++ algorithm optimizations
# Navigate to the engine directory
cd engine
# Build the engine
make build
# Run the engine directly (UCI mode)
./chess3001
Use make help
to see all available build options.
If you prefer to use the engine with a standard chess GUI:
- Download a UCI-compatible chess GUI (e.g., Arena Chess)
- Configure the GUI to use the
chess3001
executable - Start a new game with the engine
The Chess3001 backend is a Ruby Sinatra REST API that provides an interface between the frontend and the chess engine.
- Simple JSON-based API for interacting with the chess engine
- Endpoints for retrieving board state, making moves, and resetting games
- Cross-origin resource sharing (CORS) support for frontend integration
- Custom command handling for communicating with the UCI engine
# Navigate to the backend directory
cd backend
# Install required gems
gem install sinatra json sinatra-cross-origin
# Start the API server
ruby chess_api.rb
The server will run on http://localhost:4567
.
GET /api/board
Returns the current board state in FEN notation.
POST /api/move
Request body:
{
"move": "e2e4"
}
Makes the specified player move and returns the updated board state.
POST /api/reset
Resets the game to the starting position.
- The API uses the
fen
command (instead ofd
) to retrieve the FEN string representation of the board - The engine returns the raw FEN string without any prefix
- All endpoints use the
/api/
prefix for consistency and clarity
The Chess3001 frontend is a modern React application that provides a user-friendly interface for playing against the chess engine.
- Modern React-based user interface
- Interactive chessboard with drag-and-drop move capability
- Real-time game state synchronization with the backend
- Responsive design for desktop and mobile play
# Navigate to the frontend directory
cd frontend
# Install dependencies
npm install
# Start the development server
npm start
The frontend will be available at http://localhost:3000
.
- Uses the native fetch API with explicit CORS mode and headers
- Connects directly to the backend at http://localhost:4567
- Includes detailed error handling for connection issues
Before getting started, ensure you have:
-
For the Engine:
- Latest version of
g++
compiler make
build system- Windows, Linux, or macOS
- Latest version of
-
For the Backend:
- Ruby 2.6+
- Sinatra gem
- JSON gem
- sinatra-cross-origin gem
-
For the Frontend:
- Node.js and npm
- React
To contribute to Chess3001:
- Fork this repository
- Create a branch:
git checkout -b feature_branch_name
- Make your changes and commit them:
git commit -m 'Add some feature'
- Push to the original branch:
git push origin feature_branch_name
- Create a pull request
See GitHub's documentation on creating a pull request.
Pedro Luis |
This project is licensed under the terms specified in the LICENSE file.