SebLague / Chess-Challenge

Create your own tiny chess bot!
https://www.youtube.com/watch?v=Ne40a5LkK6A
MIT License
1.77k stars 1.06k forks source link

Add member IsWhiteToMoveInt #395

Closed an-inconspicuous-semicolon closed 1 year ago

an-inconspicuous-semicolon commented 1 year ago

Whilst the IsWhiteToMove can be used in boolean logic to determine the colour that is moving, math cannot. IsWhiteToMoveInt will fix this by enabling bots to get a number they can multiply against.

For example, when using a numerical evaluation that has white as positive, the bot can multiply against IsWhiteToMoveInt at each step in the search tree to find if the evaluation is better for the current player or opponent.

mcthouacbb commented 1 year ago

what's wrong with IsWhiteToMove ? -1 : 1

an-inconspicuous-semicolon commented 1 year ago

It's that I believe that IsWhiteToMoveInt is identical to IsWhiteToMove in functionality, but since you will need it in quite a few places, having to spend an extra 5+ tokens every time makes the problem slightly harder for no good reason, similar to #380. Having to either recalculate the value everywhere it is used, or pass it through call trees. when the same information is already presented by the Board class, is in my opinion, sub-optimal