Wednesday, January 9, 2019

Exotherm - Time management

After yesterday's intelligence improvements, Exotherm took quite a bit of time to move, regardless of the time control. Today I worked on improving its time management. The main move determination function now takes three time-related parameters: minimum time, minimum depth, and maximum time. It explores the move tree for at least the minimum time unless it runs out of moves to explore. It then continues until it reaches the minimum depth in the tree or runs out of the maximum time. The FICS interface script currently uses 1/40 the remaining time as the minimum, 1/12 as the maximum, and 2 as the minimum depth. This worked as intended - the bot doesn't usually lose on time even in fast games, but of course its play deteriorates when it gets under time pressure.

There are two main factors that determine the bot's strength: move evaluation time and which positions get evaluated. Until today it wasn't very good about reducing the latter: it would bail out if it had win-in-one but otherwise it would search all paths equally. Today I added a notion of "finished" nodes. When a child node is a win-in-one, it sets its parent as finished - when you can win immediately, there's no point in doing anything else. When the main loop encounters a node with a finished parent, it skips growing the tree from that node.

Since I'm new to Python, I don't know how to optimize processing speed. A suggestion I discovered was to run the script under PyPy, an alternative JIT-compiled Python interpreter. So I installed that, ran it, and found an order-of-magnitude increase in evaluations! Exotherm can now evaluate about 17,000 positions per second. Using skipping, it can sometimes even get to a depth of 5 in reasonable time.

No comments:

Post a Comment