bitboard library
Native-only bitboard chess core: board representation, move generation, make/unmake, FEN, and perft.
Do not import this from code that compiles to JavaScript. Bitboards are
64-bit and rely on 64-bit integer literals and operations, which are not
representable under dart2js (web ints are doubles). Native (Dart VM / AOT)
only. The web build must reach the engine through the package search that
runs on package:chess, never this library.
Classes
Constants
- bishop → const int
- black → const int
- castleBK → const int
- castleBQ → const int
- castleWK → const int
- castleWQ → const int
- fileABb → const int
- fileHBb → const int
- flagCapture → const int
- flagDoublePush → const int
- flagEpCapture → const int
- flagKingCastle → const int
- flagPromoCaptureKnight → const int
- flagPromoKnight → const int
- flagPromoQueen → const int
- flagQueenCastle → const int
- flagQuiet → const int
- fullBoard → const int
- All-ones 64-bit mask (== -1 as a signed VM int).
- king → const int
- knight → const int
- pawn → const int
- Piece type indices.
-
pieceValue
→ const List<
int> - Centipawn material values, indexed by piece type (pawn..king).
- queen → const int
- rook → const int
- startposFen → const String
- white → const int
- Colors.
Properties
-
kingAttacks
→ List<
int> -
final
-
knightAttacks
→ List<
int> -
Pop the least-significant set bit, returning its index. Mutates via return:
callers use
sq = lsb(bb); bb &= bb - 1;.final -
pawnAttacks
→ List<
List< int> > -
final
Functions
-
bishopAttacks(
int sq, int occ) → int -
Bishop attacks from
sqgiven full-boardoccupancy. -
encodeMove(
int from, int to, int flag) → int -
evaluateMaterialPst(
Position p) → int - Material + piece-square tables only. Kept as the A/B baseline for the extra terms in evaluatePosition (self-play verification).
-
evaluatePosition(
Position p) → int - Static evaluation from the side-to-move's perspective, in centipawns.
-
lsb(
int bb) → int -
Index of the least-significant set bit.
bbmust be non-zero. -
moveFlag(
int m) → int -
moveFrom(
int m) → int -
moveIsCapture(
int m) → bool -
moveIsCastle(
int m) → bool -
moveIsEnPassant(
int m) → bool -
moveIsPromotion(
int m) → bool -
movePromoType(
int m) → int - Promotion piece type (knight..queen) for a promotion move.
-
moveTo(
int m) → int -
msb(
int bb) → int -
Index of the most-significant set bit.
bbmust be non-zero. -
perft(
Position p, int depth) → int -
Count leaf nodes at
depth— the standard move-generator correctness test. -
popcount(
int bb) → int - Number of set bits. Kernighan's method; fine for eval-frequency use.
-
queenAttacks(
int sq, int occ) → int -
Queen attacks from
sqgiven full-boardoccupancy. -
rookAttacks(
int sq, int occ) → int -
Rook attacks from
sqgiven full-boardoccupancy.