Multithreading AI is now in...

I wasn't sure we'd get this in by the beta but it was a really nice day out today so I took the laptop out for the afternoon on the deck and decided it was time to get the multithreading going.

The AI now calculates its strategy during YOUR turn.

Previously:
Player hits the TURN button, the game then goes and updates all the planets, updates all the ships, AI calculates its various strategies and assign ships, researches, etc. Then when completed the turn button re-enables.

NOW:
When you begin your turn, in the background the above takes place. When you click on the turn button, all it does now is actually move the ships on screen (can't do that in a thread unfortunately) and then checks to see if AI is done and if other updates are done and then moves on.

Result:
If you're just wailing on the turn button, nothing has changed. However, if you take mor ethan say a second to take your turn (which hopefully you are) then the delay between turns is less.

On top of that, it allows us to have the AI do a lot more thinking. I can have functions that don't have to be completed before the end of turn but instead it only worries about them every 10 turns or so. So the AI could go and do really complex pattern matching in the background without it slowing down the game.

That said, we're still not happy with the performance in gigantic galaxies. The issue is pathfinding. The original OS/2 version basically didn't have any. This version has the same type of path finding you'd find in an RTS. But that pathfinding can be lengthy to calcuate and occurs when the ship moves. So if a ship is wanting to move to the other side of the galaxy, that can be a problem. The solution is, of course, to have it only solve the pathing for as far as it actually needs to go but that's actually quite a bit more work than it initially appears but that's what we'll eventually have to do I suspect. But that won't be in for the beta, so gigantic galaxies will still be a bit painful.

We've also increased the frames per second through cleaning up our drawing code so that the game is much more responsive than previously.
348 views 4 replies