Distributing AI processing

I’m developing some AI for a board game, but having problems with cpu spikes

it is a kind of “race game”, where the players have certain goals to achieve. All movement is guided by nodes, i’m using A* for the player to be able to find a way to the goals, and thats all perfect till now, however in this game players are able to manage the nodes, connecting and disconnecting them through some game mechanics

my problem is that when i have the AI checking for possibilities for modifying the node connections, it become quite expensive to check for all possibilities and get the best one.

Would like to know if there’s a way, and what would it look like, to divide code like this (mostly for loops) so that the AI will “take some time” for doing a decision, instead of lagging everything, in a single-threaded language like actionscript :slight_smile:

Any suggestions?

Thanks in advance.