← Back to team overview

widelands-dev team mailing list archive

Re: multithreading thoughts

 

Hi,


> As you mentioned multithreading today and as the performance is indeed a problem I have this very simple idea on multithreading:
> 
> First some background:
> 
> The widelands 'core' does own stuff and inbetween calls DefaultAI::think() for all players one after one.
> 
> I believe these DefaultAI::think() can be run in pararel, as they do not change state (buildings, roads, anything) on the map during the time they run. (Or am I wrong?)

I think you are, but I am not 100% sure about that. I know very little about the AI code having written nothing of it. But in general, that would be my idea of using multithreading for the AI too: make a clear interface of control that can be used by the networked, local and AI players and “gather” the commands in parallel. 

> Once they are all done, widelands core can start doing own stuff, including executing commands (called functions) given by AI. Now widelands could find that some orders (like construct a building/road) can not be executed due to changes on the map, but these functions would only fail quietly. This happens also now and causes no problem to AI. At the same time all AIs would be informed on changes on map, mainly changes in buildings (this is how it is done also now). And then again, all AIs would be called in pararell.
> 
> I understand multithreading is not task of a day now, I just wanted to share with my ideas :)

Thanks for that. I think it is useful to think about ways of making the AI parallel. The logic seems to fit easily on one core.


Attachment: smime.p7s
Description: S/MIME cryptographic signature


References