An empty array size 4000x4000 is fine, size 5000x5000 it crashes. What are better options?

0 favourites
  • 9 posts
From the Asset Store
A versatile and wide-ranging selection of large to medium-sized creature sounds.
  • If I open a new project and add an empty array

    size 4000x4000x3 and run it, it's fine (48,000,000 elements)

    size 5000x5000x1 and it crashes (25,000,000 elements)

    size 10,000x1,000x10 it is also fine. (100,000,000 elements)

    I am looking for an alternative option of storing integers that is size 960,000x32,000x3 (92,160,000,000 elements)

    I use the array to hold terrain values for my games world map, but I use it sparingly and in a way that so far has almost no lag.

    Tagged:

  • I am filling one z axis of the array with perlin noise values so I have a feeling that if I broke the map into many arrays that the noise wouldn't be so perliny on chunk edges

  • Well I can't answer the array size limitation question... but I can say normally I wouldn't store what is I'm assuming your entire world's procedurally generated values in an array to begin with. You should be able to look up a value at any given position for a particular seed any time you want, so just get the relevant values as you need them from a function.

    Alternatively, if you must have the values in an array, you can split your arrays into chunks (can still be a single array object, with multiple instances). Use x/y instance variables to keep track of the relative position of each array, and have each array's size be whatever you're comfortable with that doesn't crash.

    I'm just guessing here, but I think the array size limitation is based on your system, so I'd stay well away from that threshold if I were you, since your end users' systems might not be as capable as your own.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I am filling one z axis of the array with perlin noise values so I have a feeling that if I broke the map into many arrays that the noise wouldn't be so perliny on chunk edges

    With the same seed, as long as you're consistent with your coordinate system, there should not be any seams at whatever chunk edge you define.

  • Thank you! I am new to using noise so I didn't realize that the seed was so useful! I understand how this would solve the issue completely. Although, the player is able to lower and raise the perlin noise value in the array to change the terrain. When the player leaves and returns to the chunk and the seed is used for the terrain, what could I do to affect that value by the amount the player has previously changed that value?

  • Hmm if you need to keep track of modifications to the noise, then you might want to have it in an array after all. I personally would still approach it by recording only what is necessary rather than everything at once though.

    Again, you could break it into chunks, Minecraft style, where you keep an array instance per chunk and have a system to keep track of the relative location of each array/chunk

  • Thank you, I understand how that solution would work! Does this rely on RAM where if there are lots of arrays in existence that aren't being used, the game will still slow?

  • Yes, but I believe the ram usage for a text based object like an array is generally negligible. At some point you will not be able to hold an infinite amount of data in memory, but that should be given.

    You're more likely going to run into cpu limitations first when trying to process the all the data in huge arrays, which again emphasizes minimizing the scope of whatever you are doing to only what is relevant at any given point.

  • I've been pretty good at that so far, I'll have to think some time for how I'll implement this, but I know what needs to happen <3 thank you so much for help!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)