Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor Move representation #2126

Draft
wants to merge 25 commits into
base: master
Choose a base branch
from
Draft

Conversation

mooskagh
Copy link
Member

@mooskagh mooskagh commented Feb 22, 2025

Main motivation was to have consistent move representation in the Move struct, particularly:

  • Castling is always encoded as "king takes rook", doesn't matter whether we are in chess960 mode or not.
  • The difference only appears during converting from/to string representation.

Some cascading changes:

  • Instead of int row, int col which were very error prone, have a File/ Rank struct (strong typedef rather). Now all places are converted yet.
  • NN index lookup for a given move is moved to neural/encoder
  • Move now has en passant and castling bits, but it also simplifies movegen a bit.
  • The main reason for the castling bit is to be able to convert a move to a string without knowing the position.
  • Bitboard.cc had no code left, was removed.

Next planned steps in this area (before rewriting the search):

  • Make Move always be "from white perspective", e.g. e7e5 by black remains encoded as e7e5.
  • Combine Position with ChessBoard
  • Try changing intrinsics to C++ std:: intrinsics.

While we don't have unit tests (and we will after the refactoring!), I'm doing the manual testing now:

  • Search from white/black positions (caught a bug!)
  • Ponder as white/black (caught a bug!)
    Will also check the selfplay and PGN book.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant