1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-04-30 16:53:09 +00:00

Rewrite messy LSN-code

* New version is documented and logic should be easier to follow
* Add extra check to not use LSN with x moves / y seconds time control
* New code fixes some rear cases where old code (still) causes program to lose on time at move 1.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
Joona Kiiski 2009-11-25 00:14:12 +02:00 committed by Marco Costalba
parent 9a59535962
commit cd0c7373cd

View file

@ -526,23 +526,41 @@ bool think(const Position& pos, bool infinite, bool ponder, int side_to_move,
<< " moves to go: " << movesToGo << std::endl; << " moves to go: " << movesToGo << std::endl;
// We're ready to start thinking. Call the iterative deepening loop function // LSN filtering. Used only for developing purpose. Disabled by default.
// if (UseLSNFiltering)
// FIXME we really need to cleanup all this LSN ugliness
if (!loseOnTime)
{ {
Value v = id_loop(pos, searchMoves); // Step 2. If after last move we decided to lose on time, do it now!
loseOnTime = ( UseLSNFiltering if ( loseOnTime
&& myTime < LSNTime && myTime < LSNTime // double check: catches some very rear false positives!
&& myIncrement == 0 && myIncrement == 0
&& v < -LSNValue); && movesToGo == 0)
}
else
{ {
loseOnTime = false; // reset for next match
while (SearchStartTime + myTime + 1000 > get_system_time()) while (SearchStartTime + myTime + 1000 > get_system_time())
; // wait here ; // wait here
id_loop(pos, searchMoves); // to fail gracefully } else if (loseOnTime) // false positive, reset flag
loseOnTime = false;
}
// We're ready to start thinking. Call the iterative deepening loop function
Value v = id_loop(pos, searchMoves);
// LSN filtering. Used only for developing purpose. Disabled by default.
if (UseLSNFiltering)
{
// Step 1. If this is sudden death game and our position is hopeless, decide to lose on time.
if ( !loseOnTime // If we already lost on time, go to step 3.
&& myTime < LSNTime
&& myIncrement == 0
&& movesToGo == 0
&& v < -LSNValue)
{
loseOnTime = true;
}
else if (loseOnTime)
{
// Step 3. Now after stepping over the time limit, reset flag for next match.
loseOnTime = false;
}
} }
if (UseLogFile) if (UseLogFile)