fixed time control management

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

Daniel Shawul
Posts: 4185
Joined: Tue Mar 14, 2006 11:34 am
Location: Ethiopia

fixed time control management

Post by Daniel Shawul »

In a fixed time control (with/without increments) I set fixed number of moves left (35) to calculate search time. Changing this to something dynamic that assumes chess games end in 40 moves on average performed much better to my surprize. It got +30 elo on short time controls (game in 40sec), but as we know time management changes are very sensitive and this could easily evaporate on a bit longer time control.

Code: Select all

if&#40;move_no <= 25&#41; moves_left = 40 - move_no;
else moves_left = 15;
search_time = p_time / moves_left + inc;
I used to set moves_left = 30 before for all phases, but this new scheme plays faster towards the endgame. I wish this could translate to the standard time controls ( 40 moves in X minutes)as well, but so far uniform time allocation is still good there. Thought I had stepped on a gold mine there, but probably a trickery peat :)
AlvaroBegue
Posts: 931
Joined: Tue Mar 09, 2010 3:46 pm
Location: New York
Full name: Álvaro Begué (RuyDos)

Re: fixed time control management

Post by AlvaroBegue »

You also need to make it a bit smarter, by making the numbers depend on the setting of the "ponder" option: You can be somewhat more aggressive in consuming time if every so often you'll save some time because of a ponder hit.
User avatar
Evert
Posts: 2929
Joined: Sat Jan 22, 2011 12:42 am
Location: NL

Re: fixed time control management

Post by Evert »

Interesting. I've always done what you're doing now (let number of assumed remaining moves depend on the number of moves played already), and I decided to see if I could simplify by just setting a constant number of moves remaining instead. It was a clear regression.
User avatar
hgm
Posts: 27793
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: fixed time control management

Post by hgm »

It would be more logical to not let the remaining-moves estimate depend on the absolute move number, but on the game phase. In mini-Shogi, where there isn't really a game phase (because it is a drop game like Crazyhouse), I use the score to estimate remaining move. The farther you are from equality, the quicker you expect the game to end.

I do this dynamically: rather than deciding before the search how long I want to think, it re-calculates the limit on every clock read, based on the most recent root score.

In orthodox Chess, with so many games available, it should of course be easy to take statistics. The main difficulty is deciding when games are decided. In any game there comes a situation where you can win it against perfect play in virtually zero time, but for games played upto checkmate, this might still take most of the moves. You want to distribute the remaining time over the moves where there was still something to think about, If you could determine that point in every game, it would be easy to determine the distribution of remaining moves for each given (game-phase, score imbalance) pair.
zamar
Posts: 613
Joined: Sun Jan 18, 2009 7:03 am

Re: fixed time control management

Post by zamar »

hgm wrote:
In orthodox Chess, with so many games available, it should of course be easy to take statistics. The main difficulty is deciding when games are decided. In any game there comes a situation where you can win it against perfect play in virtually zero time, but for games played upto checkmate, this might still take most of the moves. You want to distribute the remaining time over the moves where there was still something to think about, If you could determine that point in every game, it would be easy to determine the distribution of remaining moves for each given (game-phase, score imbalance) pair.
In Stockfish, the statics were taken wit assumption that the game is decided when either side has >275cp advantage. This works fine for short, medium and long time controls. But not for hyper blitz.
Joona Kiiski
thomasahle
Posts: 94
Joined: Thu Feb 27, 2014 8:19 pm

Re: fixed time control management

Post by thomasahle »

My statistics, posted here, suggest that your approximation is pretty good. Only try updating the constants as

Code: Select all

if&#40;move_no <= 20&#41; moves_left = 45 - move_no; 
else moves_left = 25; 
It would be interesting to make a regression over the function (moves_played, material_total, material_difference) -> moves_left. Seems like you'd be able to get something pretty precise. Maybe also take the time controls into consideration.
Daniel Shawul
Posts: 4185
Joined: Tue Mar 14, 2006 11:34 am
Location: Ethiopia

Re: fixed time control management

Post by Daniel Shawul »

Nice. I will try the log-normal formula and see if i I get an improvement.
Thanks.
thomasahle
Posts: 94
Joined: Thu Feb 27, 2014 8:19 pm

Re: fixed time control management

Post by thomasahle »

Depending on what time controls you are going to use your engine with, you might also try with a different dataset.
Adam Hair
Posts: 3226
Joined: Wed May 06, 2009 10:31 pm
Location: Fuquay-Varina, North Carolina

Re: fixed time control management

Post by Adam Hair »

thomasahle wrote:My statistics, posted here, suggest that your approximation is pretty good. Only try updating the constants as

Code: Select all

if&#40;move_no <= 20&#41; moves_left = 45 - move_no; 
else moves_left = 25; 
It would be interesting to make a regression over the function (moves_played, material_total, material_difference) -> moves_left. Seems like you'd be able to get something pretty precise. Maybe also take the time controls into consideration.
Interesting. The same data for computer matches is similar in that it is also approximately lognormal, but the length of the games is longer:

CCRL 40/4
mean=141 (half moves)
median=129
mode=115

CCRL 40/40 (early adjudication is commonly used for these games)
mean=137
median=126
mode=122
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: fixed time control management

Post by bob »

Daniel Shawul wrote:In a fixed time control (with/without increments) I set fixed number of moves left (35) to calculate search time. Changing this to something dynamic that assumes chess games end in 40 moves on average performed much better to my surprize. It got +30 elo on short time controls (game in 40sec), but as we know time management changes are very sensitive and this could easily evaporate on a bit longer time control.

Code: Select all

if&#40;move_no <= 25&#41; moves_left = 40 - move_no;
else moves_left = 15;
search_time = p_time / moves_left + inc;
I used to set moves_left = 30 before for all phases, but this new scheme plays faster towards the endgame. I wish this could translate to the standard time controls ( 40 moves in X minutes)as well, but so far uniform time allocation is still good there. Thought I had stepped on a gold mine there, but probably a trickery peat :)
I think this divisor is much less important that paying attention to the game, and adjusting the target time on the fly, as I am doing in Crafty. If you change your mind a couple of times during an iteration, ramp up the target. If you stick with the same move, iteration after iteration, reduce the target. I tested this over many games last year, it it helps much more than just increasing or decreasing the target time uniformly based on some static criteria.