Procedural generation number of arrays slowing down system

Get help using Construct 2

Post » Sat Oct 21, 2017 7:51 pm

Message: gskunk can only post plain text URLS until they have 500 rep. 1 URLS modified. Why?
Here's an image of the event list (7 events) The locator line does not speed things up when disabled. The 'arraySubChunks' is set to 100x100. The layout will finish fine with sizes ranging from 1x1 to around 30x30.
Last edited by gskunk on Sat Oct 21, 2017 7:54 pm, edited 1 time in total.
Posts: 13
Reputation: 255

Post » Sat Oct 21, 2017 7:53 pm

Um, reading image data takes a tick fwiw.
Posts: 8,722
Reputation: 128,812

Post » Sat Oct 21, 2017 7:57 pm

Yes I understand that. The image data is not slowing anything down anymore than I expected it to. I can populate the master array (the one the size of the image fine) with the data I need just fine. The problem that occurs is when creating an array for every pixel on the map. Without that occurring, even with reading the image data, it still flies through everything and pumps it into the master array just fine.

EDIT: Just tried creating an additional switch state that would fire once the initial master array populating was finished and create the secondary arrays there, just to eliminate any possibility that the image reading was causing the hang up. Still causing the same issue.
Posts: 13
Reputation: 255

Post » Sat Oct 21, 2017 8:23 pm

100x100 x 30x30 x8 is 72Mb
100x100x 100x100 x8 is 800Mb
Saving it to disk as json will be quite a bit larger since each number no longer only takes 8byte but usually more depending on the number.

But idk. you can always generate less than a row in an array at a time. Still i only have a vague idea of what's going on. Good luck with the project.
Posts: 5,591
Reputation: 85,520

Post » Sun Oct 22, 2017 12:17 am

gskunk wrote:dop2000 - 25x25 is just where it starts to faulter. I'm really trying to aim for 100x100. Think of each pixel of the heightmap as a chunk of the map. The idea is to take every chunk and expand it into a second array so that chunk is in reality 100x100 tiles. I do realize this is an absurd amount of data. As far as reusing the array I could, but wouldn't that wind up in losing the processed data. I suppose I could dump it to json after ever single cell expansion of the main map. Would be a lot of files being created however.

Still, why do you need to hold all 10.000 chunks of the map in full detail in memory at all times?
Take Google Maps approach - it loads a portion of the map only when you zoom into it.
You can load/generate a block of 3x3 chunks to allow players to move freely and load new chunks once they move to a new area.

Also, how do you populate that second array? If it's randomly generated, you should use seeded random, this will allow you to store just one number in the first array (the seed) and you will not need the second array at all! You will be able to recreate the data in each chunk of map at any time from the seed.
And if your player makes some changes on the map (kills enemies, opens chests etc.) and you need to keep track of these changes, maybe consider creating another array just for that. It could be something as simple as [tile, newdata].
This will save you hundreds Mbytes of memory.

EDIT: You can go even further and get rid of the first array too! :)
Compress your entire 100 million tiles map into a single number - MasterSeed.
Use MasterSeed and a pixel from your heightmap image to generate MapChunkSeed, then use MapChunkSeed to generate 100x100 tiles portion of the map. You probably should be able to do this in real-time with very little or no lag.

Did I help to fix a problem in your game? You can buy me a cup of coffee :) If you'd like to hire me, please see this post
Posts: 2,401
Reputation: 84,429

Post » Tue Oct 24, 2017 12:43 am

Random seeding would indeed be the best way to go about this. Thanks all for your input.
Posts: 13
Reputation: 255


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 0 guests