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

Small simplication of see_ge() #1242

Closed

Conversation

syzygy1
Copy link
Contributor

@syzygy1 syzygy1 commented Sep 3, 2017

Two simplifications:

  • Remove the initialisation to 0 of occupied, which is now unnecessary.
  • Remove the initial check for nextVictim == KING. If nextVictim == KING, then PieceValue[MG][nextVictim] will be 0, so that balance >= threshold is true. So see_ge() returns true anyway. To make this a bit more explicit, I have added corresponding initialisers to the PieceValue[][] array in psqt.c. (Interestingly, PSQT::init() already loops from W_PAWN to W_KING, so including the VALUE_ZERO values for W_KING seems to make sense for that reason alone.)

I don't think the later test in see_ge() for nextVictim == KING can be removed so easily, but I did not investigate thoroughly.

Running this on fishtest seem unnecessary, but let me know.

No functional change.

Two simplifications:
- Remove the initialisation to 0 of occupied, which is now unnecessary.
- Remove the initial check for nextVictim == KING. If nextVictim == KING, then PieceValue[MG][nextVictim] will be 0, so that balance >= threshold is true. So see_ge() returns true anyway. To make this a bit more explicit, I have added corresponding initialisers to the PieceValue[][] array in psqt.c. (Interestingly, PSQT::init() already loops from W_PAWN to W_KING, so including the VALUE_ZERO values for W_KING seems to make sense for that reason alone.)

I don't think the later test in see_ge() for nextVictim == KING can be removed so easily, but I did not investigate thoroughly.

Running this on fishtest seem unnecessary, but let me know.

No functional change.
@mcostalba
Copy link

Merged with 741523e

I have removed the init part because redundant: global variables are zero initialized at startup (technically there is even no zero init involved, simply the OS maps process's global variables in a set of new memory pages that are ensured to be zero before to be mapped into user space).

@mcostalba mcostalba closed this Sep 5, 2017
@syzygy1 syzygy1 deleted the see_ge_simplification branch September 16, 2017 22:59
MichaelB7 pushed a commit to MichaelB7/Stockfish that referenced this pull request May 26, 2020
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.

2 participants