- Home /
Preventing circles in dungeon generation?
I've been working on a script the last couple of days, that generates a random dungeon as you walk through it. My current problem is that I cant prevent the tiles from forming a circle and ending the maze. I made a tower tile that takes the dungeon up or down a level, so I was thinking that if I can get the tiles to detect when its about to intersect with another one it can replace the next tile with a tower tile. My problem is that I am having trouble getting it to detect this.
Here I have it make the room and push it into an array.
var newRoom : Transform = (Instantiate(wallArray[Random.Range(1,5)], transform.position, transform.rotation));
newRoom.transform.position.z = transform.position.z -= 3;
var newDoorFrame : Transform = (Instantiate(wallDoorFrame, transform.position, transform.rotation));
newDoorFrame.transform.position.z = transform.position.z -= 3;
var newDoor : Transform = (Instantiate(wallArray[6],newDoorFrame.transform.position, newDoorFrame.transform.rotation));
oldRoomPos = newRoom.position;
spawnArray.push(newRoom);
I was thinking that I could use the array to somehow tell it when it needs to change based on the last few tiles that were generated. Like if the array was (LeftCorner,Hall,LeftCorner,LeftCorner) it would make the next tile a tower. Thanks in advance, Tracey PS: I can post all the code, but its pretty lengthy.
Does your dungeon have intersections/branches or is it a winding tunnel?
Try Prim or $$anonymous$$ruskal's algorithms
http://en.m.wikipedia.org/wiki/$$anonymous$$aze_generation_algorithm
Your answer
Follow this Question
Related Questions
Rooms being spawned in the wrong places? (Random Generation) 0 Answers
How would I change my procedurally generated map change cells if it detects cells are around it? 0 Answers
why does my code tag objects it's not supposed to? 0 Answers
BSP Tree for dungeons generation, HELP! 1 Answer
Detecting contact on colliders? 0 Answers