rythwh / snowship

Snowship is a colony survival management simulation game under development since early 2015.
https://rywh.itch.io/snowship
5 stars 0 forks source link

Saving the game takes way longer than it should. #95

Open rythwh opened 3 years ago

rythwh commented 3 years ago

See comments.

Just guessing, it's probably due to saving the plants growth changes because the length of time to save the game seems directly proportional to the map size, and tiles.snowship is 75% of the overall save file when it could be closer to 10% with a more intelligent system to store plant growth progress.

Solution(s):

rythwh commented 3 years ago

I implemented the above function to do away with growthProgress and instead grow a plant randomly and instantly, however the saving performance is basically the same (and the game performance is also basically the same as iterating through a few hundred plants each in-game minute didn't really affect much).

Looking at it now it makes sense this wouldn't have really changed much, because while the size of the tiles.snowship file will likely be smaller since it only stores actually grown plants, the save performance still has to compare the entire original tiles.snowship file to the new state, which in 100x100 is 10,000 tiles, and 200x200 is 40,000 tiles, no matter how little has actually changed. It took about 40 seconds to save a 200x200 game.

On 100x100 maps it's still longer than ideal but isn't really that bad. I think the introduction of other systems like Ship will take the focus off larger single maps and instead on the player exploring multiple smaller maps.