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

Mirror the board instead of rotating when transitioning to black. #118

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Dolphus2
Copy link

The engine uses piece square tables to evaluate positions. These piece square tables are not symmetric, which means that rotating the board and viewing black as "white" effectively changes the incentives of black, since black has its king to the left of the queen rather than the right. As such, where the white king starts on the king pst space with value 6, the black king starts on -14 and is incentivized to move one space left or right, because the king pst models it as having already castled. This cannot be right.

Another example is that if you evaluate the value of the starting position of black and white, it comes out to a difference of (6-13) - (-14-31) = 38 in favour of white because of the reversed position of the king and queen according to the piece square tables. This is true even if black starts and is just an artifact of the non-symmetry of the piece square tables. But chess is equivalent if black starts, so it does not make sense that white should have an advantage in this case.
These are two quite simple, illustrative examples, but this influences the engine's positional play all the way down the search tree.

The starting positions of white and black are identical when mirrored horizontally. Thus if the board is instead mirrored horizontally, then piece square tables will be correctly applied to both black and white. This is the only thing this pull request changes. I have implemented two static methods in the Position object to make the change very clear, but you are welcome to change it as you see fit.
Thank you for this nice chess engine.
board_original
board_rotated

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.

None yet

1 participant