Saturday, October 10, 2015

Use your time wisely

A very old part of iCE is the time management module. As soon as I had it robust enough so that my engine does not lose on time anymore I left it alone.

Its mechanism is actually pretty simple. In the usual time control with x moves in y minutes it just divides the remaining time by the number of remaining moves to come up with a desired time for a move. It allows stretch to allow the engine to finish an iteration.

Also if there is still some time left but probably not enough to finish at least one move of a new iteration it does not start it.

This mechanism dates back to iCE 0.3 and hasn't been changed since. Recently I revisited the code and tried to improve it. Surprisingly it turned out to be very difficult to come up with something better than the simple mechanism above. Also it does not make sense to test changes with my usual set of very fast games. To play enough games to get some statistical confidence here takes much much longer.

One idea that failed was to allocate more time for early moves. This is a very common scheme in other engines but it did not help in iCE. Maybe I haven't tested it enough but none of my versions passed the regression test.

A small success was a little change to the time allocation for the last moves before the next time control. Nothing to write home about. The improvement was about 6 ELO with an error margin of 8. So there is even a chance for a small regression but I keep the change as I like the code and think it makes more sense than the previous allocation.