For those interested in internals of efficient programming techniques:
Chess "AI" engines: this AI in name pre-dates modern neural network based models.
It was just indication of clever heuristics embedded in chess-playing programs.
This is necessary, since the game of chess has potentially very large number of combinations
so efficiency is very important.
Usually, every of 64 chess squares is represented by one char or int.
The number of possible values is very small: P R N B Q K (white) and p r n b q k (black).
So the simplest solution is a string of 64 chars, or an array of 64 int values, or even int8 or uint8 (byte)
Also, to help with handling moves generation, this is usually "padded" to 120 or 128 chars.
Note: "char" in many prog languages is taking 2 Bytes of space (UTF16)
Now, processing strings and arrays is relatively fast,
but apparently not as fast as processing on "bit" level.
Bitboards - Chessprogramming wiki
Here is LLM AI explanation
Bitboards (Most Powerful & Modern Engines Use This)
What it is:
-
64-bit integers where each bit represents a square.
-
One bitboard per piece type per side (e.g., 1 for white pawns, 1 for black rooks, etc.)
-
You use bitwise operations to manipulate positions quickly.
Example (in Python):
Pros:
-
Very fast with bitwise logic
-
Perfect for parallel move generation and evaluation
-
Used by strong engines (Stockfish, Lc0)
Cons:
Here are some examples of "Bitboard" based open source chess engines
kurt1288/KhepriChess: Chess engine written in TypeScript, from scratch. Browser and UCI support. @GitHub
wlivengood/Winston: A Chess Engine Written in Javascript @GitHub
engines - Faster bit-board implementation in Javascript - Chess Stack Exchange
Should I use bitboards or mailbox for my A level project? : r/chessprogramming