Mar 23, 2014

Hilarious trouble



A I predicted in the previous post. Precalculation algorithm gone wild.
Theoretically, if the map is completely free, game should make about 40 millions of pathfinding calculations per Z level(!).
Of course, it is impossible to have such map, but frankly, even halve of this quantity is enough to dream about painful execution for the author of the game.
How do I plan to fix that?
First of all, we don’t have to do all calculations every sing time.
For example we have this tiles:
1 2 3
4 5 6
7 8 9
We have done calculations for clusters 1-4 and now, we start cluster 5. We don’t need to recalculate its connections with clusters 1-4. Because, if the check said, you can’t reach cluster 5 from cluster 1, it works vice versa, doesn’t it?
Good, we cut good the load of calculations!
Next step Is multithreading, I mentioned before. I tried It already for couple of times and was really amused.
Yes, I knew that multithreading ≠ multiprocessing, but on the application level it is nearly the same.
 Modern multicores CPU are great doing tons of routine calculations simultaneously. You just have to help it a bit and designate them for this. My plan is to cut map into smaller units. For example 10 blocks and start every single block as thread.
It would make CPU to work hard on it. We have main thread free and would entertain player writing about game lore and world, that has been generated.
As for me, I can wait even a dozen of minutes or more, if the game tells me what is going on, what cool stuff it generates and doesn’t just look dead.

I really want to finish it ASAP and start drug&drop.

No comments:

Post a Comment