4

Ok so, I'm making a 2d dungeon crawler and I want to randomize a map for it. Right now it's look like I'm going to use a Random Walk algoritm for the path, combined with a Perlin Noise for different the underworld enviroments (currently only 1, as I'm using my own shitty looking tile set consisting of only 1 rook image and 1 grass image, but whatever :D)

So in figuring out how random walks work, it looks like I'm supposed to do something along the lines of this:

*create two-dimensional array sized after the map.

*pick random start postion and end postiont (I chose to put these on opposite sides of the map, randomly distributed across its side.

*follow these steps until you hit your finish point:

*pick a direction to 'walk' at random (only up, down, left, right because you otherwise I'm left with diagonal passes which the player can't walk through)

*'walk' that direction for a random amount of steps (I randomize amount of steps first then walk one by one for bound checking later, rather than just drawing a line).

*Everytime you 'walk' on a tile, turn that tile to 1 from originally 0.

*repeat above steps until you hit your finish point.

This leaves me with too much open ground, and too much closed ground. What I'm looking for is a path covered with rooms, sort of, but I want to control how big the 'rooms' become. I don't want 'rooms' to get too big, which some become. So I want the feeling of being in an enclosed space, but also I want to use as much of the map grid as possible.

Is a random walk not suited for this? I was thinking about making every step have a certain width to it, maybe that could work.

Or maybe I'm just implementing it wrong! I'm not a math genious sadly ;P

MPelletier
  • 16,256
  • 15
  • 86
  • 137
Sebastian Zander
  • 347
  • 1
  • 4
  • 13
  • out of curiosity, why do you choose a direction and number of steps rather than just choose a direction each step? (this is not a critique, I think your problem is interesting and I'm just trying to appreciate the scenario) – Robot Woods Jul 03 '12 at 00:32
  • To gaurantee corridors. Randomizing the number of steps shouldn't change anything except it's a tool to create corridors. It sort of works. – Sebastian Zander Jul 03 '12 at 02:27
  • UPDATE (if anyone's intresting): I've come up with a way to create a random path (corridor) between multiple points (which for now are the egressions from the dungeon, there will be many dungeons which are part of a large system). Basically, I cycle between the points and each cycle, every point 'walks' a random direction a random amount of steps. Every point it 'walks' is basically saved. Every walk is checked for validity, can't walk into other out-ofbound areas or other paths. If it walks into something unvalid it will go back. Repeat this until it's forced to go back to the original point. – Sebastian Zander Jul 04 '12 at 16:05
  • 2
    @PutBoy Why don't you put that as an answer to this question (which you then can accept, and which then can be voted on) ? – moooeeeep Nov 05 '15 at 07:43

0 Answers0