Q:

Saving an arbitrary sized 2d array

I'm trying to create an arbitrary sized(but not infinite) 2d tilebased world. My question is, how do i save a world like this?
My idea was to split up the tiles into bigger chunks and then save those seperately. Let's say you have a world of 5000x5000 tiles, each chunk would be 50x50 and saved in a seperate file. This leaves me with 10000 seperate files, which does not seem optimal. Is there a better way?

A:

This is usually ideal - you can also further decide to split things into 'regions'. This is pretty similar to how Minecraft does things and you can probably learn a lot from just examining it. Splitting it into multiple file sis ideal because while it does incur a penalty for opening the file still, it makes things manageable and prevents large seeking times on a single large file on slower drives. You can read up on this post here for more information on the method. Essentially, what you had in mind is a good idea - just try and minimize chunks into optimal amounts. Good luck!

