The Daily Click ::. Forums ::. Klik Coding Help ::. Random level/dungeon generator?
 

Post Reply  Post Oekaki 
 

Posted By Message

Muz



Registered
  14/02/2002
Points
  6499

VIP MemberI'm on a BoatI am an April FoolHonored Admin Alumnus
8th October, 2003 at 21:33:48 -

I could make a level/dungeon editor, so don't worry about about explaining that part. The problem is trying to make a good random level/dungeon generator.

For one thing, how do you make it so the tiles fade neatly onto each other? You know, like how grass would fade into beach before fading into water.

Then there's placement of mountains, caves, cities, and all that other stuff...

As for dungeons, how do you make those rooms with the corridors?


If someone would be kind enough to teach me how to make these, I'll try to repay thee with a turn-based game using the engine with your name in the credits...

 
Disclaimer: Any sarcasm in my posts will not be mentioned as that would ruin the purpose. It is assumed that the reader is intelligent enough to tell the difference between what is sarcasm and what is not.

Image

Radix

hot for teacher

Registered
  01/10/2003
Points
  3139

Has Donated, Thank You!VIP MemberGOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!GOTW WINNER CUP 4!
8th October, 2003 at 23:47:39 -

Here's how I'd do it (I'm thinking of a roguelike game). Create every possible tile or tile groups (for example, a bunch of different corridor pieces including walls, some standard rooms and some parts of rooms, and door-filling bits of walls to serve as dead ends), and then have an ini or something containing all the possible links. For example a verticle corridor tile can join to another verticle corridor, any room with a door above or below, and an up- or down-pointing T-intersection.

From the start tile, create a random tile in a random direction, then another from that one, then another from that one. When an adjoining tile is created, a flag is set (for example, a room with a door on the top, bottom an left might use flags 0,1,3), as is the flag indicating the direction of the previous room in the new one. When a dead end occurs, the game randomly picks a tile, checks its flags and begins building a new path. When all the flags are set, the dungeon is complete. I'd recommend using a counter to make sure the exit is a certain distance from the entrance. And since this would take a while I'd write it to an INI before the player enters the room, and have all your dungeons built during a load screen before the game starts.

As for having tiles fade into one another, you could just use the above method and make sure grass can only lead into a half grass/sand tile, and grass/sand can only become grass or sand. I'm prettu much clueless on how to randomly generate a decent oveworld though.

 
n/a

Jimmy Brzezicki



Registered
  16/09/2003
Points
  1057
14th October, 2003 at 09:22:32 -

Grizzlies 2 uses a random level generator that works in a linear fashion. It prints one object to backdrop, and then randomises (based on it's current object) the next appropriate tile. For example, if the current tile is flat, it could choose to go up, down, or continue flat. If it's going up, it could continue to go up or level off. You can download the game if you want to see it in action. Grizzlies 3 (which isn't quite done yet, preview soon) uses a more advanced version of the same system, where there are multiple "flat" or "up" tiles, or transitional tiles (eg up to flat) and this gives a very organic feel to the levels.

 
Why the hell am I on the computer at 1 in the morning? No, don't answer.

Muz



Registered
  14/02/2002
Points
  6499

VIP MemberI'm on a BoatI am an April FoolHonored Admin Alumnus
17th October, 2003 at 09:42:12 -

Radix: That sounds like it could work. Thanks.
Jimmy: I'll try to download it as soon as I have time. Thanks.
Paul: I'm sure the X-Com series had pre-drawn maps. Well, at least 2,3,4 and 5 did. Not sure about UFO Defense. If only I could get my hands on that game... my collection would be complete...

 
Disclaimer: Any sarcasm in my posts will not be mentioned as that would ruin the purpose. It is assumed that the reader is intelligent enough to tell the difference between what is sarcasm and what is not.

Image

cake



Registered
  13/12/2002
Points
  1173
17th October, 2003 at 23:34:53 -

Ok, I just wrote an explaination that would generate random dungeons, but honestly, it is so massive and complex I just saved it as a file and won't bother posting it. I think it could only be done in a programming language anyway, and even then only *maybe*, but with MMF? Haven't got a chance...

 
n/a

Muz



Registered
  14/02/2002
Points
  6499

VIP MemberI'm on a BoatI am an April FoolHonored Admin Alumnus
18th October, 2003 at 09:45:52 -

Could you post it anyway? Maybe a link to the file or something. Almost anything (cept 3D calculations) is possible in MMF...

 
Disclaimer: Any sarcasm in my posts will not be mentioned as that would ruin the purpose. It is assumed that the reader is intelligent enough to tell the difference between what is sarcasm and what is not.

Image

Doplegager



Registered
  19/06/2003
Points
  23
21st October, 2003 at 12:38:26 -

The solution I usually use for random terrain generation is a bit object-heavy, so I'm not sure how useful it'll be.

Basically, I design a mini-map of the appropriate size and randomly generate the basic details of the tiles (grassland, mountain, water, etc). Nine 'sensors' are placed on the mini-map, one for the player's current location and one for each of the eight possible directions. That way you know where you are, and all of the possible places you could be going.

For my games, the central 'sensor' determines the appearance of the center of the window while the outlaying 'sensors' create areas of transition along the edge of the window so that the player(s) can smoothly move from one terrain type to another. Quality of transition all depends on how detailed you go into coding the interactions between the 'sensors'.

Most of the work I use this for goes to games like Zelda, but I imagine it could be altered for a seamless scroller.

The nice part is that you can laden the tiles in the mini-map with values; whenever the player enters tile 9F, the computer creates a temple. When they leave, the temple is erased so it doesn't hog memory. You can get pretty complex with that stuff (9-27 variables per tile can theoretically make a fairly rich world).

Theoretically, every mini-map tile could represent multiple 'tiles' in the game. Never got that part to work just right, though. Imagine turning a 10x10 tile mini-map into a 30x30 window world.

Of course, I'm still using KnP, so there are probably better solutions with the newer software.

Image Edited by the Author.

 
"All of my life, I had wanted to be a comic book artist. It had been my one dream, my one goal."
-The Disgruntled Artist, Second Story
available at www.geocities.com/magnetmanga
   

Post Reply



 



Advertisement

Worth A Click