View Single Post
Old 12-01-2012, 06:10 PM   #1
koteko
New Member
 
Join Date: Mar 2012
Posts: 20
koteko is on a distinguished road
A huge grid world

I had written a big post but the browser crashed, so I'm going to make it short.

In my MUD engine, I'm trying to decide whether to go for the standard area-based world or if to try to make it more coerent (yet less flexible, builder-side) using a huge matrix.

Mine is going to be a big universe, describable by a 4-dimensional matrix of pointers to Room objects: world[planes_n][x][y][z]. The planes are probably going to be 5, each one with at most 1000x1000 rooms. The "z" coordinate is needed because I want to allow digging tunnels and flying in the skies freely.

Doing some calculation, I ended up with this:

1000x1000 pointers (4 bytes on a 32 bits system) to room objects (each one, for simplicity, let's say big 100 bytes), 5 planes, 5 layers under the ground and 5 layers for the skies (so 11 possible values for the "z" coordinate) occupy a bit more than 5GB of RAM ((5*1000*1000*11*4 + 5*1000*1000*11*100) bytes if you were curious). Without counting objects, mobs and players. With 32bit the JVM is able to allocate at most 2GB so...I have a problem.

Just the pointers to the rooms occupies about 40 megabytes, so trying to reduce as much as possible the size of a single room object is a must. Maybe trying to reuse the same room object for some parts of the world (especially the skies) would do the job, but I don't really know how to do it consindering the players will together move into the same sky-rooms.

I'm also bugged about the limit which I am obliged to put to the "z" coordinate, which with this area-less system determines the height of the buildings (maximum five floors over the ground) and the depth of dungeons (maximum 5 levels under the ground).

Of course there are things I can think of to reduce the memory usage, like the underground and the skies are instantiated at running time and made persistent only when an user actually use it and modify it while digging tunnels or creating a flying house. Or I could make some of the planes smaller than 1000x1000, and/or reduce the world grid to 1000x500 or even less.

I just thought I'd post here my doubts to get some feedback. I'm aware odds are that you are already using an area-based system, but do you think it would work with a fully persistent, modifiable world? Do you have any ideas on how to reduce the memory usage with a grid-based universe like mine?

Last question: do you think a seamless world of 1000x500 rooms is too big? I'm going to allow the building of villages/towers from players, that I guess make a small world little apt to my needs.

Thank you from any advice you'll be able to give me.

Last edited by koteko : 12-01-2012 at 06:42 PM.
koteko is offline   Reply With Quote