Skip to content

GC Chess Engine: A powerful and efficient UCI compatible engine, built with C++ and Bitboard optimizations.

Notifications You must be signed in to change notification settings

DhaniAAA/GC-Chess_Engine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

76 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

GC-Engine - A UCI Chess Engine

A powerful chess engine written in C++ with support for the Universal Chess Interface (UCI) protocol.

Version Language License Platform


๐Ÿ“‹ Table of Contents


โœจ Features

Search

  • Iterative Deepening with aspiration windows
  • Principal Variation Search (PVS) / Alpha-Beta pruning
  • Quiescence Search with quiet check generation
  • Transposition Table with multi-bucket hashing
  • Multi-Threading support (Lazy SMP)
  • Move Ordering:
    • Hash move / TT moves
    • Captures ordered by MVV-LVA and SEE
    • Killer moves (2 per ply)
    • Counter move heuristic
    • History heuristic
    • Continuation history (1-ply and 2-ply)

Pruning & Reductions

  • Null Move Pruning with verification search
  • Late Move Reductions (LMR) with dynamic adjustments
  • Late Move Pruning (LMP)
  • Futility Pruning with depth-based margins
  • Reverse Futility Pruning (Static Null Move)
  • Razoring with depth-scaling margins
  • SEE Pruning for captures and quiet moves
  • Delta Pruning in quiescence search
  • Multi-Cut Pruning
  • ProbCut
  • Internal Iterative Reductions (IIR)
  • History-Based Pruning (Leaf, Counter, Followup)

Extensions

  • Check Extension
  • In-Check Extension
  • Singular Extension with multi-cut and double extensions
  • Recapture Extension
  • Passed Pawn Extension (7th rank)
  • Capture Extension (SEE-based)
  • PV Extension
  • Mate Threat Extension
  • Negative Extension for unexpected fail-highs

Evaluation

  • Tapered Evaluation (Middlegame/Endgame interpolation with non-linear phase scaling)
  • Material & Piece-Square Tables (incrementally updated)
  • Pawn Structure:
    • Passed pawns with connected bonus
    • Candidate passed pawns
    • Isolated, doubled, backward pawns
    • Phalanx and connected pawns
    • Pawn duo bonus
    • King proximity to passed pawns (endgame)
    • Blockaded passed pawn penalty
    • Rook behind passed pawn bonus
    • Rule of the Square bonus
  • Piece Activity:
    • Mobility for all pieces (contextual evaluation)
    • Knight outposts
    • Knight tropism (distance to enemy king)
    • Bishop pair bonus
    • Bad bishop detection
    • Connected rooks bonus
    • Rook on open/semi-open files
    • Rook on 7th rank
  • King Safety:
    • Attack units table with weighted attackers
    • Pawn shield evaluation
    • King ring / inner king ring attacks
    • Open/semi-open file penalties
  • Threats Evaluation:
    • Piece threats from pawns
    • Minor piece and rook threats
    • Hanging pieces detection
  • Space Evaluation
  • Tempo Bonus
  • Lazy Evaluation for speedup in won/lost positions
  • Pawn Hash Table for efficient pawn structure caching

Other Features

  • UCI Protocol full support
  • Opening Book support (Polyglot format)
  • Syzygy Tablebase support (via Fathom)
  • Multi-PV analysis mode
  • Pondering with ponderhit support
  • Advanced Time Management with stability-based adjustment and panic mode
  • Contempt and Dynamic Contempt options
  • SPSA Tuning support for parameter optimization
  • Texel Tuning support for evaluation tuning
  • Built-in Profiler for performance analysis
  • Benchmark command for reproducible testing

๐Ÿ”ง Building

Requirements

  • C++17 compatible compiler:
    • GCC 7+ (recommended: GCC 10+)
    • Clang 5+
    • MSVC 2017+
  • GNU Make (or MinGW Make on Windows)

Quick Build

๐ŸชŸ Windows (MinGW)

# Standard release build
mingw32-make

# Clean and rebuild
mingw32-make clean; mingw32-make all

# Build and run
mingw32-make run

๐Ÿง Linux

# Install dependencies (Ubuntu/Debian)
sudo apt-get update && sudo apt-get install -y g++ make

# Standard release build
make

# Clean and rebuild
make clean && make all

Advanced Build Options (Windows)

# Debug build (no optimization, with symbols)
mingw32-make debug

# Build with PEXT/BMI2 support (Intel Haswell+, AMD Zen 3+)
mingw32-make pext

# Profile-Guided Optimization (PGO) - Step 1: Generate profile
mingw32-make pgo-generate
# Run benchmarks: ./output/main.exe bench
# Step 2: Use profile data
mingw32-make pgo-use

# PEXT + PGO for maximum performance
mingw32-make pext-pgo-generate
# Run benchmarks: ./output/main.exe bench
mingw32-make pext-pgo-use

# Internal profiling build (for performance analysis)
mingw32-make internal-profile

# Texel Tuner build
mingw32-make tuner

Build Output

Platform Executable Location
Windows output/main.exe
Linux output/main

๐ŸŽฎ Usage

UCI Mode

Run the engine and it will automatically start in UCI mode:

./output/main.exe

UCI Commands

Command Description
uci Display engine info and available options
isready Check if engine is ready
ucinewgame Start a new game (clears hash table and history)
position [fen | startpos] [moves ...] Set position
go [options] Start search
stop Stop current search
ponderhit Opponent played the expected ponder move
quit Exit engine

Go Command Options

Option Description
depth N Search to depth N
nodes N Search N nodes
movetime N Search for N milliseconds
wtime N White time remaining (ms)
btime N Black time remaining (ms)
winc N White increment per move (ms)
binc N Black increment per move (ms)
movestogo N Moves until next time control
infinite Search until stopped
ponder Start pondering

Non-Standard Commands

Command Description
perft N Run perft test to depth N
divide N Run divided perft to depth N
d Display current board position
eval Show static evaluation of current position
bench [depth] [threads] [hash] Run benchmark (default: depth 13, 1 thread, 16MB hash)

๐Ÿงช Testing

Quick Tests

# Test perft (move generation correctness)
echo "perft 5" | ./output/main.exe

# Test search
echo "go depth 10" | ./output/main.exe

# Run built-in benchmark
echo "bench" | ./output/main.exe

# Run benchmark with custom settings
echo "bench 15 4 256" | ./output/main.exe  # depth 15, 4 threads, 256MB hash

Perft Results (Verified)

Position Depth Nodes Time
Starting 5 4,865,609 ~1.3s
Starting 6 119,060,324 ~74s
Kiwipete 4 4,085,603 ~0.4s

Test Suites

The engine includes several test suites in the tests/ directory:

File Description
wac.epd Win at Chess positions
bratko_kopec.epd Bratko-Kopec test suite
see-test.epd Static Exchange Evaluation tests

Gauntlet Testing

Use the provided batch scripts for automated testing against other engines:

# Run gauntlet against multiple engines
./run_gauntlet.bat

# Run SPRT testing
./run_sprt.bat

๐Ÿ™ Acknowledgments


๐Ÿ“„ License

This project is open source. Feel free to use, modify, and distribute.


๐Ÿ‘จโ€๐Ÿ’ป Author

Dhani - GC-Engine Development


Happy chess programming! โ™Ÿ๏ธ

About

GC Chess Engine: A powerful and efficient UCI compatible engine, built with C++ and Bitboard optimizations.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published