mirror of
https://github.com/sockspls/badfish
synced 2025-04-30 00:33: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:
parent
9a59535962
commit
cd0c7373cd
1 changed files with 32 additions and 14 deletions
|
@ -526,23 +526,41 @@ bool think(const Position& pos, bool infinite, bool ponder, int side_to_move,
|
|||
<< " moves to go: " << movesToGo << std::endl;
|
||||
|
||||
|
||||
// We're ready to start thinking. Call the iterative deepening loop function
|
||||
//
|
||||
// FIXME we really need to cleanup all this LSN ugliness
|
||||
if (!loseOnTime)
|
||||
// LSN filtering. Used only for developing purpose. Disabled by default.
|
||||
if (UseLSNFiltering)
|
||||
{
|
||||
Value v = id_loop(pos, searchMoves);
|
||||
loseOnTime = ( UseLSNFiltering
|
||||
&& myTime < LSNTime
|
||||
// Step 2. If after last move we decided to lose on time, do it now!
|
||||
if ( loseOnTime
|
||||
&& myTime < LSNTime // double check: catches some very rear false positives!
|
||||
&& myIncrement == 0
|
||||
&& v < -LSNValue);
|
||||
}
|
||||
else
|
||||
&& movesToGo == 0)
|
||||
{
|
||||
loseOnTime = false; // reset for next match
|
||||
while (SearchStartTime + myTime + 1000 > get_system_time())
|
||||
; // 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)
|
||||
|
|
Loading…
Add table
Reference in a new issue