This weekend I’m working on optimizing memory usage in the game. This requires a lot of testing that involves having the AI play against the AI on the largest possible map with lots of players. Now, late game, there’s only a handful of players left (in the video above you can probably figure out how many) but the times can take a lonnng time.
Let me first ask those of you reading this, how many of you have played the beta on a large map with lots of players with >500 turns into it? It gets slow. There are thousands of units and dozens of cities and lots of things going on. Each unit has its own armor, weapons, enchantments, equipment, rings, etc. And each turn, the game has to go and evaluate all these to see if the various cached values need to be updated – and late game, they often do.
So in a bit of frustration, I bit the bullet and created a worker thread for each AI. In FE 0.86, the player and “the AI” move simultaneously. In my build, the player and each AI player moves simultaneously.
This could only be done because of the work in the past few months of making the game much more thread safe. So it’s a good robustness test to be able to not just have a few “dedicated” threads where each thread has a specific job. Now, we can toss threads around as needed and let your multi-core machines take care of the rest.
Or put another way, the idea of putting all these into their own threads is pretty obvious. The ability to actually do this safely is the key element here.
Oh, in case you’re wondering, in my example the end turn wait went from 8 seconds to 2 seconds in my massive, mega game.