Threading the AI - an idea
Posted: 31 May 2012, 06:51
This is based on a question asked here
By this I am talking about having the AI (when its the AIs turn to process information) through each AI player into a thread pool and have them process that thread independently rather than in turn. Overall, AI only has one thread but each player AI gets to do its chores on its own rather than collectively. This may not work well for combat units but should work out ok for trucks and overall combat strategies, perhaps research choices and anything that doesn't require advanced concepts (locks etc.).
Which got me to thinking... If we are to attempt to thread the AI then why not do so for EACH ai per frame instead of all AIs running in order. For advanced AIs or a true learning AI this would spread the load around. I know in python this could be done each frame as threads are built into python. Not sure about the WZ script/js. The only option would be to have a copy of each script running in a separate thread.NoQ wrote:No.Maybe it would be possible to put that routine into a seperate thread, so the CPU can work on it simoutaniously?
The reason is that the scripts work with copies of game objects (and there is a good reason for that too). These copies may get outdated if used in a different game frame. So even if the computation done in the script can be parallelized, the script can't run in background of the game itself. Each event needs to get handled before the game can advance further.
By this I am talking about having the AI (when its the AIs turn to process information) through each AI player into a thread pool and have them process that thread independently rather than in turn. Overall, AI only has one thread but each player AI gets to do its chores on its own rather than collectively. This may not work well for combat units but should work out ok for trucks and overall combat strategies, perhaps research choices and anything that doesn't require advanced concepts (locks etc.).