Skip to content

pedrol3001/Chess3001

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

25 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Chess3001

GitHub repo size GitHub language count GitHub stars GitHub forks Bitbucket open issues Bitbucket open pull requests

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.

πŸ—οΈ Project Structure

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

πŸš€ Chess Engine

The core of Chess3001 is a powerful chess engine written in C++ that implements various advanced chess programming techniques.

Features

  • 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

Building the Engine

# 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.

Using with Chess GUIs

If you prefer to use the engine with a standard chess GUI:

  1. Download a UCI-compatible chess GUI (e.g., Arena Chess)
  2. Configure the GUI to use the chess3001 executable
  3. Start a new game with the engine

🌐 Backend API

The Chess3001 backend is a Ruby Sinatra REST API that provides an interface between the frontend and the chess engine.

Features

  • 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

Setup

# 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.

API Endpoints

Get Board State

GET /api/board

Returns the current board state in FEN notation.

Make a Move

POST /api/move

Request body:

{
  "move": "e2e4"
}

Makes the specified player move and returns the updated board state.

Reset Game

POST /api/reset

Resets the game to the starting position.

Implementation Notes

  • The API uses the fen command (instead of d) 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

πŸ’» Frontend

The Chess3001 frontend is a modern React application that provides a user-friendly interface for playing against the chess engine.

Features

  • 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

Setup

# 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.

Implementation Notes

  • 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

πŸ“‹ Prerequisites

Before getting started, ensure you have:

  • For the Engine:

    • Latest version of g++ compiler
    • make build system
    • Windows, Linux, or macOS
  • For the Backend:

    • Ruby 2.6+
    • Sinatra gem
    • JSON gem
    • sinatra-cross-origin gem
  • For the Frontend:

    • Node.js and npm
    • React

🀝 Contributing

To contribute to Chess3001:

  1. Fork this repository
  2. Create a branch: git checkout -b feature_branch_name
  3. Make your changes and commit them: git commit -m 'Add some feature'
  4. Push to the original branch: git push origin feature_branch_name
  5. Create a pull request

See GitHub's documentation on creating a pull request.

πŸ‘₯ Collaborators

Pedro Luis Github Foto
Pedro Luis

πŸ“ License

This project is licensed under the terms specified in the LICENSE file.

⬆ Get to the top