SquareSet class is chessops’ implementation of a bitboard - an immutable set of squares represented as a 64-bit integer. It provides efficient set operations and is fundamental to move generation and board representation.
SquareSet Class
An immutable set of squares implemented as a bitboard using two 32-bit integers:Creating SquareSets
Static Constructors
fromSquare
Create a SquareSet containing a single square:fromRank / fromFile
Create a SquareSet containing all squares on a rank or file:Predefined Sets
Color-Specific Sets
Set Operations
Boolean Operations
union
Combine two sets (bitwise OR):intersect
Get common squares (bitwise AND):diff
Remove squares from the set (set difference):xor
Symmetric difference (bitwise XOR):complement
Invert the set (bitwise NOT):Set Comparison
Single Square Operations
Checking Membership
Adding and Removing Squares
Querying SquareSets
Size and Emptiness
Getting Specific Squares
Removing First Square
Iteration
Forward Iteration
SquareSet implementsIterable<Square>, so you can use for-of loops: