Add support for Op1 tablebase positions#1192
Merged
Merged
Conversation
MarkZH
reviewed
Mar 22, 2026
Comment on lines
+1060
to
+1067
| for file_idx in range(8): | ||
| wp_ranks = [chess.square_rank(sq) for sq in white_pawns if chess.square_file(sq) == file_idx] | ||
| bp_ranks = [chess.square_rank(sq) for sq in black_pawns if chess.square_file(sq) == file_idx] | ||
|
|
||
| if wp_ranks and bp_ranks and min(wp_ranks) < max(bp_ranks): | ||
| return True | ||
|
|
||
| return False |
Collaborator
There was a problem hiding this comment.
Instead of this searching, you can directly query which squares the pawns are on. Something like
if white_pawns.popcount() != 1 or black_pawns.popcount() != 1:
return False
wp = white_pawns.pop()
bp = black_pawns.pop()
return square_file(wp) == square_file(bp) and square_rank(wp) < square_rank(bp)
Collaborator
There was a problem hiding this comment.
There are mistakes in my code. I thought op1 meant exactly one white pawn and one black pawn, not at least one of each. So, I'm probably wrong about searching not being necessary.
Also, white_pawns.popcount() should be len(white_pawns).
Collaborator
There was a problem hiding this comment.
This actually works, I'll leave it to you to decide if it's easier to read.
if not white_pawns or not black_pawns:
return False
for wp in white_pawns:
for bp in black_pawns:
if chess.square_file(wp) == chess.square_file(bp) and chess.square_rank(wp) < chess.square_rank(bp):
return True
return False
Member
Author
There was a problem hiding this comment.
Switched as it seems cleaner.
MarkZH
approved these changes
Mar 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Type of pull request:
Description:
Adds support for querying op1 tablebase positions. Details about op1 are here.
Related Issues:
None
Checklist:
Screenshots/logs (if applicable):