Skip to content

Add support for very large boards and guard Omega variant#13

Closed
Belzedar94 wants to merge 1 commit intomasterfrom
codex/implement-256-bit-bitboard-for-16x16-7hy0ow
Closed

Add support for very large boards and guard Omega variant#13
Belzedar94 wants to merge 1 commit intomasterfrom
codex/implement-256-bit-bitboard-for-16x16-7hy0ow

Conversation

@Belzedar94
Copy link
Copy Markdown
Owner

Summary

  • add a 256-bit Bitboard implementation and board geometry constants to enable VERY_LARGE_BOARDS builds up to 16×16
  • allocate file/rank masks and rider attack tables at runtime for very large boards, switching to on-the-fly sliding attacks when tables would explode in size
  • update Omega chess to the 12×12 layout and register it only for VERY_LARGE_BOARDS builds, along with refreshed Python regression data and help text for the new build targets

Testing

  • make build -j2 ARCH=x86-64
  • make build -j2 ARCH=x86-64 verylargeboards=yes
  • python3 test.py (fails with a segmentation fault when importing pyffish built with VERY_LARGE_BOARDS)

https://chatgpt.com/codex/tasks/task_e_68cc5e69d3348322beb185dbec93be00

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codex Review: Here are some suggestions.

Reply with @codex fix comments to fix any unresolved comments.

About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you open a pull request for review, mark a draft as ready, or comment "@codex review". If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex fix this CI failure" or "@codex address that feedback".

Comment on lines 407 to +448
for (Square s = SQ_A1; s <= SQ_MAX; ++s)
SquareBB[s] = make_bitboard(s);

#if defined(VERY_LARGE_BOARDS)
std::array<Bitboard, FILE_NB> fileMask{};
std::array<Bitboard, RANK_NB> rankMask{};
AllSquares = Bitboard(0);
DarkSquares = Bitboard(0);

for (File f = FILE_A; f <= FILE_MAX; ++f)
for (Rank r = RANK_1; r <= RANK_MAX; ++r)
{
Square sq = make_square(f, r);
Bitboard bb = SquareBB[sq];
fileMask[f] |= bb;
rankMask[r] |= bb;
AllSquares |= bb;
if (((int(f) ^ int(r)) & 1) == 1)
DarkSquares |= bb;
}

std::array<Bitboard*, FILE_NB> fileGlobals = { &FileABB, &FileBBB, &FileCBB, &FileDBB,
&FileEBB, &FileFBB, &FileGBB, &FileHBB,
&FileIBB, &FileJBB, &FileKBB, &FileLBB,
&FileMBB, &FileNBB, &FileOBB, &FilePBB };
for (int f = 0; f < FILE_NB; ++f)
*fileGlobals[f] = fileMask[f];

std::array<Bitboard*, RANK_NB> rankGlobals = { &Rank1BB, &Rank2BB, &Rank3BB, &Rank4BB,
&Rank5BB, &Rank6BB, &Rank7BB, &Rank8BB,
&Rank9BB, &Rank10BB, &Rank11BB, &Rank12BB,
&Rank13BB, &Rank14BB, &Rank15BB, &Rank16BB };
for (int r = 0; r < RANK_NB; ++r)
*rankGlobals[r] = rankMask[r];

int halfFiles = FILE_NB / 2;
QueenSide = Bitboard(0);
KingSide = Bitboard(0);
for (int f = 0; f < halfFiles; ++f)
QueenSide |= fileMask[f];
for (int f = halfFiles; f < FILE_NB; ++f)
KingSide |= fileMask[f];
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1] Initialize bitboard constants before constructing variants

The new VERY_LARGE_BOARDS implementation moves AllSquares, RankNBB, FileNBB, KingFlank, etc. from compile‑time constants to globals that are populated inside Bitboards::init() (this block). Existing startup paths call variants.init() before Bitboards::init() (e.g. in main.cpp and in the Python wrapper), and Variant’s default regions are initialized using those globals. With the values still zero when variants.init() runs, the variants end up with empty masks and the pyffish build segfaults when it accesses those regions. Either move Bitboards::init() ahead of variants.init() or provide constexpr defaults so the variant data is valid during construction.

Useful? React with 👍 / 👎.

@Belzedar94 Belzedar94 closed this Sep 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant