ID:152148
 
So here's my plan. I have these special 500x500 areas which must be entirely randomly generated and filled with content, in the middle of a live game. These areas will have mountain ranges, rivers, lakes, and other such geographical features.

I know random map generation itself involves a lot of math and cellular automata and stuff, I've never really made random maps before though.

What I want to know is how does it happen in BYOND? How exactly do you make new dmm files on the fly and load them into the server? I looked at the files for a DMM and all it looks like is a simple text file with an array of characters representing tiles. Since you could pretty much edit and create maps with a text editor, it seems like you could create a seperate C program or something to create maps.

I already have the following:
1) A new map handler datatype
2) A sort of hash table for referencing a map handler quickly by Z level.

I know some really basic techniques for random generation involves making rooms and making connections and stuff, which is good for a dungeon but this is for outdoor generation, and I haven't found too many resources for that. I guess what I want from this thread is:

1) Advice to keep in mind
2) Links to resources that may be helpful
3) Discussion on this topic
There is no built-in functionality for loading a .dmm file at runtime. However, there have been multiple libraries created which provide that (or similar) functionality. The first that comes to mind is SwapMaps by Lummox JR. That's a good choice. It does not actually save or load .dmm files, but uses its own format (actually: DM's savefile format).

As for an example of an algorithm to generate the map, the only one that comes to mind right now is this one.
In response to Garthor
What if you didn't create new maps but simply allocated empty maps for future use? And then edited them?

I could do that, because I know for a fact there will be a limit on the number of random maps available at any one time.
In response to Obs
The changes to the map at runtime would not make a modification to the .dmm files. You can export to a .dmm file, and read a .dmm file at runtime and generate a map based off of it, but as there's no built-in functionality you may as well just use SwapMaps, so as not to reinvent the wheel.

There is a library somewhere that will save and load map files at runtime, but I think it uses the .dmp format... and I really don't know if there's a difference between .dmp and .dmm.
In response to Garthor
Garthor wrote:
You can export to a .dmm file, and read a .dmm file at runtime and generate a map based off of it,


Can you reclarify this, it sounds contradictory to what you said before.

Maps are only loaded once at the start of the server?
In response to Obs
Sorry, I mean that you can code all that functionality yourself, but there's nothing built-in to generate new maps. Also: creating empty space in the .dmm is unneeded, because it's possible to change the world.maxx/y/z variables to change the size of the map at runtime, which then just gets filled in with the default turf (world/turf). My point is that any changes done at runtime are not made to the .dmm file, and you'd have to write your own functionality for that from scratch if you wanted it.
In response to Garthor
Didn't know map sizes could change. Interesting.

Anyway, when you say that changes made to a map at runtime are not made to the dmm file, are you saying that once the game shuts down the randomly generated map is lost? If changes aren't being made to the dmm file, what exactly does that really mean?

If I take a map and create a mountain in it, players will see the mountain but the DMM file will not show it?
In response to Obs
Right, in the same way that mobs moving around on the map aren't going to be making any changes to the .dmm file.
In response to Garthor
Isn't this what save files are for? Or can save files not save an altered .dmm
In response to Obs
savefiles have their own format. You can save to a .dmm file if you're willing to write all the translation code yourself, or you can save to a savefile (which is what SwapMaps will do for you).
In response to Garthor
My map loading library, pif_MapLoader, loads and saves in the .dmm/.dmp format. There were no changes I'm aware of, and I'm working on getting 3.0 out. I hope to get it done over break.
In response to Garthor
Ok, so swapmaps can save a randomly generated map so that people could play on it later.


Now, I'd rather focus on building this actual map. You said maps can be resized, what happens if I resize a map in the Z direction? does it create more areas?

I guess I'm thinking what I'd have is blank 1x1 map, and when I want to make a new map, I resize that to 500x500. Then when I make a new map, resize to 500x500x2? 2 maps?

After this is done, is it really a matter of going through cell by cell and deciding what cell will be what turf? First, I know byond optimizes turfs or something by representing thousands of them as the same one in memory if they are all identical, but what about these turfs generated randomly? Do they all count as distinct locations in memory, thus hogging up all of the servers RAM? 250,000 turfs?
In response to Popisfizzy
Popisfizzy wrote:
My map loading library, pif_MapLoader, loads and saves in the .dmm/.dmp format. There were no changes I'm aware of, and I'm working on getting 3.0 out. I hope to get it done over break.

Does this mean people can edit the map offline?
In response to Obs
If you have multiple map files, they are compiled into a single very large map, with each map file (in alphabetical order) becoming a z-level (or series of z-levels) in the final map. All z-levels have their x and y dimensions scaled to be equal with the largest map.
In response to Garthor
So you can't resize larger than the largest map?
In response to Obs
It'll give you an error if you try and edit it in Dream Maker, unless they have all the object definitions, but you can edit a DMM file in a text editor. It's a rather straight-forward format.
In response to Popisfizzy
Popisfizzy wrote:
It'll give you an error if you try and edit it in Dream Maker, unless they have all the object definitions, but you can edit a DMM file in a text editor. It's a rather straight-forward format.

yea. Are savefiles just as easy to edit?
In response to Obs
You can. But every z-level must have the same x and y dimensions (there is only one world.maxx and world.maxy), so smaller maps will have area filled in so that they are the same size as the largest map.
In response to Obs
Their plaintext format isn't, but they can be easily edited by anyone with basic knowledge of the /savefile datum. A quick way to keep people from tampering with a DMM file is to simply encrypt the data. Mike H (under his old Airmapster key) has an RC5 library that would be perfect for encrypting it.
In response to Obs
There are the ExportText and ImportText procs for savefiles which allow you to view them, edit them, and save them in a human-readable format. I don't believe the actual files created are easily readable, though.
Page: 1 2