rspeer/dominiate — Issue #67: AI spends too much time evaluating impossible actions
Author: bilts
Created: 2012-01-19 04:30:31+00:00
State: open

I've been profiling the simulator. Web stuff aside, a very large amount of time is being spent in chooseByPriorityAndValue, particularly when it calls actionPriority.

actionPriority ends up evaluating the relative merits of every action in the game for the current game state every time it is called. This is very wasteful.

In most cases, simple AIs will have a very simple decision, e.g. do I play my Smithy? In many cases, the answer is always yes. As things stand, though, that AI is stuck considering how it'd rank its Smithy against a Spice Merchant, even if Spice Merchant isn't available in the game.

I'm not sure exactly how to fix this without really messing with how AIs are written, but it has a big impact on performance (around 20% of the sim run time, likely more for allocation/GC).