BBC
BBC, (Bit Board Chess)
a didactic bitboard chess engine by Maksim Korzh alias Code Monkey King, written in C. BBC is subject of a YouTube video tutorial started in summer 2020 [1], actually work in progress.
The open source engine is further published on GitHub [2], and will be compliant to the UCI protocol.
While the series offers a nice introduction in chess engine programming and bitboard techniques,
the advanced approach of Magic Bitboards to determine sliding piece attacks with all its lengthy initialization topics might be hard to understand and deterrent for the intended novice target group.
The linewise approaches of First Rank Attacks to introduce occupancy lookups, followed by Kindergarten Bitboards - as intermediate step towards magics bitboards - seem didactically more appropriate. Anyway, a valuable video series covering various aspects of computer chess programming. BBC 1.0 was released on September 24, 2020 [3], BBC 1.3 utilizing Stockfish NNUE on October 21, 2020 [4].
Contents
See also
Forum Posts
- Comparing 4 move generators: 0x88 vs 10x12 vs 10x12 + bitboards HYBRID vs Pure MAGIC BITBOARDS by Maksim Korzh, CCC, August 28, 2020
- Bitboard CHESS ENGINE in C: YouTube series by Code Monkey King by Maksim Korzh, CCC, September 06, 2020
- Zobrist hashing tutorials on YouTube by Maksim Korzh, CCC, September 19, 2020
- BBC 1.0 release - UCI chess engine by CMK by Maksim Korzh, CCC, September 24, 2020
- How to rate my engine in CCRL? by Maksim Korzh, CCC, September 25, 2020 » CCRL
- BBC GUI release - PLAY IT ONLINE! by Maksim Korzh, CCC, October 12, 2020 » Web GUI Tutorial
- How to scale stockfish NNUE score? by Maksim Korzh, CCC, October 17, 2020 » Stockfish NNUE, Scorpio NNUE
- Re: How to scale stockfish NNUE score? by Daniel Shawul, CCC, October 17, 2020
- Embedding Stockfish NNUE to ANY CHESS ENGINE: YouTube series by Maksim Korzh, CCC, October 17, 2020 » NNUE
- BBC 1.3 + Stockfish NNUE released! by Maksim Korzh, CCC, October 21, 2020
External Links
GitHub
- GitHub - maksimKorzh/bbc: Bit Board Chess (BBC) - The easiest to understand bitboard chess engine by Code Monkey King
- GitHub - maksimKorzh/uci-gui: Web based GUI for UCI chess engine
YouTube
BBC
Bitboard CHESS ENGINE in C
- Intro » Bitboards
- Creating comfortable conditions for development
- Generating pre-calculated PAWN ATTACK tables » Pawn Attacks (Bitboards)
- Generating pre-calculated KNIGHT ATTACK table » Knight Attacks
- Generating pre-calculated KING ATTACK tables » King Attacks
- Masking relevant bishop occupancy bits to form a key for MAGIC BITBOARDS » Magic Bitboards
- Masking relevant ROOK OCCUPANCY BITS to form a key for MAGIC BITBOARDS
- Generating SLIDER PIECES ATTACKS on the fly for MAGIC BITBOARD purposes » Sliding Piece Attacks
- Implementing BIT COUNT routine (Brian Kernighan's way) » Population Count - Brian Kernighan's way
- Getting least significant 1st BIT INDEX » Index of LS1B by Popcount
- Populating OCCUPANCY sets to multiply them later by MAGIC NUMBERS
- Generating relevant OCCUPANCY BIT COUNT lookup tables for sliding pieces
- Implementing pseudo RANDOM NUMBER generator using XORSHIFT32 algorithm » Pseudorandom Number Generator
- Generating MAGIC NUMBER candidates » Looking for Magics
- Generating MAGIC NUMBERS via brute force trial and error method
- Initializing SLIDER PIECES attack tables using PLAIN MAGIC BITBOARDS » Plain Magic Bitboards
- Defining BITBOARDS, OCCUPANCIES and helper variables » Bitboard Board-Definition
- Printing CHESS BOARD position and game state variables » Chess Position
- Parsing FEN string to initialize BITBOARDS, OCUUPANCIES & board state » Forsyth-Edwards Notation
- Getting QUEEN ATTACKS by looking up bishop & rook attack tables
- Implementing routine to find out whether SQUARE IS ATTACKED » Square Attacked By
- Writing GENERATE MOVES function skeleton »Move Generation
- Generating QUIET PAWN moves » Pawn Pushes (Bitboards)
- Generating PAWN CAPTURE moves » Pawn Captures
- Generating CASTLING MOVES » Castling
- Generating SLIDER & LEAPER piece MOVES by attack tables lookup
- Binary formatting of MOVE ITEMS » Encoding Moves
- Encoding & decoding MOVE ITEMS
- Implementing MOVE LIST + ADD MOVE, PRINT MOVE, PRINT MOVE LIST functions » Move List
- Populating MOVE LIST with newly GENERATED MOVES
- Preserving & restoring BOARD STATE aka COPY/MAKE approach » Copy-Make
- Implementing MAKE MOVE function (moving pieces) » Make Move
- Implementing MAKE MOVE function (handling captures) » Captures
- Implementing MAKE MOVE function (handling pawn promotions) » Promotions
- Implementing MAKE MOVE function (handling enpassant moves) » En passant
- Implementing MAKE MOVE function (handling double pawn pushes) » Double Pawn Push
- Implementing MAKE MOVE function (handling castling moves) » Castling
- Implementing MAKE MOVE function (updating castling rights) » Castling Rights
- Implementing MAKE MOVE function (updating occupancy bitboards) » Occupancy
- Implementing MAKE MOVE function (checking whether the king is in check) » Check
- Writing a cross-platform function for GETTING TIME IN MILLISECONDS
- Writing PERFT DRIVER function » Perft
- Writing PERFT TEST function
- Connecting to the GUI (parse move string) » GUI, UCI
- Connecting to the GUI (parse "position" command)
- Connecting to the GUI (parse "go" command)
- Connecting to the GUI (main loop) + BONUS (TSCP vs BBC blitz game) » TSCP
- Implementing RUDIMENTARY EVALUATION (material score) » Evaluation, Material
- Implementing RUDIMENTARY EVALUATION (positional piece scores)
- Writing NEGAMAX ALPHA BETA skeleton » Negamax, Alpha-Beta
- Detecting CHECKMATE and STALEMATE » Checkmate, Stalemate
- Implementing QUIESCENCE SEARCH » Quiescence Search
- Defining MVV LVA (Most Valuable Victim - Least Valuable Attacker) table » MVV/LVA
- Writing SCORE MOVE function » Move Ordering
- Writing SORT MOVES function
- Applying MOVE ORDERING to sort captures » Captures
- Sorting KILLER & HISTORY moves » Killer Heuristic, History Heuristic
- Collecting PV (Principle Variation) from the search » Principal Variation
- Implementing ITERATIVE DEEPENING » Iterative Deepening
- Sorting PV moves + some BONUS TALK at the end
- Implementing PVS (Principle Variation Search) » Principal Variation Search
- Applying LMR (Late Move Reduction) » Late Move Reductions
- Applying NULL MOVE PRUNING » Null Move Pruning
- Adjusting ASPIRATION WINDOW during iterative deepening » Aspiration Windows
- BUG ALERT!!! Fixing PVS duplication bug
- Handling TIME CONTROLS (forked from VICE by BluefeverSoftware) » Vice
- Zobrist HASHING (initialize random keys) » Zobrist Hashing
- Zobrist HASHING (generate hash key)
- Zobrist HASHING (hash keys incremental updates) » Incremental Updates
- Implementing HASH TABLE aka transposition table (define & initialize) » Transposition Table [5]
- Implementing HASH TABLE aka transposition table (read/write hash entry)
- Implementing HASH TABLE aka transposition table (connecting to search)
- BUG ALERT! Fixing lack of enpassant & side hashing on null move
- More search BUG FIXES &CLEANUPS
- Handling MATING SCORES in HASH TABLE aka transposition table » Mate Scores
- Sending MATING SCORES to GUI + some cleanups & adjustments
- Detecting THREE FOLD REPETITIONS » Repetitions
- Final (hopefully!) SEARCH BUG FIXES
- Improving EVALUATION (setting file & rank masks) » Evaluation, Pawn Pattern and Properties
- Improving EVALUATION (initializing isolated & passed pawn masks) » Isolated Pawns (Bitboards), Passed Pawns (Bitboards)
- Improving EVALUATION (double & isolated penalties, passed pawns bonus)
- Improving EVALUATION (open & semi open file scoring) » Pawns and Files (Bitboards), Open File
- Improving EVALUATION (mobility and king safety) » Mobility, King Safety
- BBC 1.0 - RELEASE
- Improving BBC chess engine: TAPERED EVALUATION (getting game phase scores) » Tapered Eval, PeSTO
- Improving BBC chess engine: TAPERED EVALUATION (interpolating scores) + BONUS: BBC vs VICE match! » Vice
GUI
Web based GUI for UCI CHESS ENGINE
- INTRO & DEMO
- Install dependencies, CREATE WEB APP & render the CHESS BOARD
- Connecting engine back-end & MAKING IT PLAY!
- Printing game status, FEN & PGN
- Adding GAME CONTROL buttons
- Adding MOVE STATS
- Fixing layout & setting position from FEN string on button click
- Adding MOVE TIME & FIXED DEPTH controls
- Implementing DOWNLOAD PGN feature
- Encapsulating CHESS ENGINE for SIMULTANEOUS PLAY
- final adjustments and DEPLOY at pythonanywhere.com
NNUE
Embedding Stockfish NNUE to ANY CHESS ENGINE
- Intro & demo » Stockfish NNUE, Scorpio NNUE
- Compiling existing ENGINE with NNUE library
- Extracting PIECES & SQUARES for direct NNUE probing
- Incorporating NNUE SCORES into EVALUATION function
- bug fixes & experiments
- WINDOWS compatibility added
- Switching to pure NNUE evaluation + important BUG FIX
References
- ↑ Bitboard CHESS ENGINE in C: intro
- ↑ GitHub - maksimKorzh/bbc: Bit Board Chess (BBC) - The easiest to understand bitboard chess engine by Code Monkey King
- ↑ BBC 1.0 release - UCI chess engine by CMK by Maksim Korzh, CCC, September 24, 2020
- ↑ BBC 1.3 + Stockfish NNUE released! by Maksim Korzh, CCC, October 21, 2020
- ↑ The Main Transposition Table from Bruce Moreland's Programming Topics