[DGD] Best method to make a wilderness map

Petter Nyström jimorie at gmail.com
Sun Feb 19 00:40:57 CET 2012


Hi Mario!

Like others, I am also curious about your experienced speed issues. It
would be interesting to learn the cause of that, if it is really a
memory management issue or not.

I have a system similar to what you describe, even though I must point
out that my implementation has never been tested in a production-like
environment. My own "wilderness map" is 1000 x 1000 rooms, which has
not caused any speed bumps with the very light usage I've given it.
Although I do suspect that it may cause DGD to run out of memory and
crash if it is used to a greater extent than what has been the case so
far.

Here are some design choices I made that may be of interest for you:

 - The 1000 x 1000 grid only stores integers that represent different
types of wilderness rooms. To display an ansi colored ascii map of the
wilderness I only need these integers, and do not have to touch any
room objects.

 - The 1000 x 1000 integer grid is actually split up over different
"sector" objects, each sector holding a part of the big grid no bigger
than 50 x 50 integers. This is to let DGD swap out parts of the map if
the memory is needed elsewhere. DGD can handle many small objects more
efficiently than one large object.

 - Actual room objects are loaded when they are needed and accessed
via a mapping. This avoids initiating a full grid with lots of nil
values when few rooms are loaded. The trade-off is slower look-up
times when more and more rooms are loaded.

 - Periodic house-keeping destroy rooms without any data that is worth
preserving.

 - When a room B would have to be loaded because an object is being
moved there from another room A (e.g. when a player walks around), if
room A has no data that is worth preserving except for the object that
is moving out of it, then instead of loading a new object for room A,
we let room A become room B. This saves us from creating a lot of new
rooms when a player spams across an otherwise deserted landscape.

Good luck!

Jimorie



More information about the DGD mailing list