bb4 / bb4-simulations

A collection of java simulations. Examples include reaction diffusion, fractals, henon phase exploration, snakes, dice, and fluid flow.
MIT License
5 stars 2 forks source link

DungeonExplorer: organic generator strategy #31

Open barrybecker4 opened 2 years ago

barrybecker4 commented 2 years ago

So far I have "bsp" and "unionGraph". The next idea to implement is "organic". For this approach, we will start with one room and then sprout other connected rooms out from it until the available dungeon area is completely filled. Additional connections, besides just those to the root, can be added as we go depending on the value of the connectivity param. This approach will have a couple of advantages:

Here is the general approach:

  1. Start with an initial randomly sized and placed room. Add 4 corridor points to a queue corresponding to the 4 sides.
  2. pop a sprout point off of the queue until there are none or the space is filled.
  3. find a space for a connected min sized + 2 room next to it.
  4. Determine a target size for that adjacent room. Grow that adjacent min-sized room until it reaches that target size +2 or hits a block (another room or corridor. Once one of those 2 things happens, backup by 2 cells to establish the new room dimensions.
  5. If a room was established, add 3 sprout points corresponding to 3 remaining sides to the queue. If a dimension is long, maybe add more than one connection point.
  6. If there is not even space for a min-sized room, depending on the connectivity thresh, create a corridor if possible.
  7. repeat from step 2 until nothing left in the queue.
barrybecker4 commented 2 years ago

Initial implementation done. Still things to do: