A random maze generator

Post » Tue Feb 16, 2016 1:43 am

Hello everyone. I made a 7 x 7 random maze generator. The cells are made from door-hallways in the 4 directions with a 4-way hall in the middle, so the cell looks like a plus sign from the top. Disabling static doors makes the maze through the halls.


I'm still a complete newbie despite staring at the scripting reference for a long time. I have an old mediafire account to put this out so people can do whatever they want with it. I am a long way from making this into something interesting but some others may be able to use it and I didn't want to complicate it to much. Perhaps some generous people may help me fix the dumb newbie stuff I have undoubtedly put in it so other beginners can better learn from it. It's not intended for public consumption it its current state. It is only found by coc unownedcell8 and it's just a bunch of twisty passages all alike at this point. To make a maze, click on the sarcophagus pillar next to the kettles. Yes, this is baby's first dungeon. To try to describe the maze generator, here's the first 50 lines from the script.



; 7 x 7 grid of cells with id from left to right, top to bottom:

; North

; 0 1 2 3 4 5 6
; 7 8 9 10 11 12 13
; 14 15 16 17 18 19 20
; West 21 22 23 24 25 26 27 East
; 28 29 30 31 32 33 34
; 35 36 37 38 39 40 41
; 42 43 44 45 46 47 48

; South

int mazeWidth = 7 ; width of the maze
int lastCell = 48 ; mazeWidth*mazeWidth - 1
int startCell = 3 ; starting cell is at north(top) center cell 3

; each cell has 4 doors, north, south, east and west, interior cells share doors
; the edge cell with the most steps from the start is chosen for the exit
; there is a long hallway which circles the outside that collects all the exits
; we only need the east and south doors of each cell to make the maze
; the north and west cell door formlists hold only maze exit doors from edge cells
; the doors were named edoor0, edoor1, sdoor0, sdoor1, etc. according to cell id
; this has kept them in order when the cell is copied and they get renamed

FormList Property mazeDoorsEast3 Auto
FormList Property mazeDoorsNorth3 Auto
FormList Property mazeDoorsSouth3 Auto
FormList Property mazeDoorsWest3 Auto

int[] path
; Path has the order in which the cells of the maze are found by adding adjacent cells.
; Negative cells in the path are (already found) junction cells for connecting another branch.
; Junction cells are found by retracing the path using a follower cell.
; The follower's purpose is to check for unchosen cells along the path, and add junctions.
; The path jumps back to the follower cell at a dead end, or if limiting the branch length.
; The follower only moves to the next path cell when all adjacent unused cells are taken.
; Follower cells in the path have a negative sign to indicate a junction for a new branch.
; Luckily, cell 0 can't be a junction with only 2 adjacent cells, so it still works.
; The follower cell gets replaced by the next cell in the path if it doesn't have a junction.
; Follower cells don't make open doors because they were discovered earlier in the path.
; Only newly discovered cells make open doors.

float relativeForward ; 'relative' probability multiplier of a forward step in the path
; relative because it adjusts the probability compared to what would normally happen
; 1.0 => always choose to move forward, 0.0 => always choose to turn, set in MakeMazePath
; 0.5 is neutral: if 2 choices, relative = actual prob, if 3 choices, the actual prob is 1/3
; relativeForward response has low slope below .5 (-> 1/3), and higher slope above (-> 1)

int BranchLimit ; longest allowable branch size, set in MakeMazePath
int branchLen ; if length > limit, treat as a dead end and jump back to the follower cell

int rngSeed ; world's worst pseudo random number generator takes rngSeed
; rngSeed <= 0 set in MakeMazePath uses Utility.RandomFloat() so a different maze each time
; set rngSeed > 0 to get the same maze each time


here are the links:


mazePathTest3.psc is in skyrim/data/scripts/source

http://www.mediafire.com/download/a64fi8k2k5rzn4z/mazePathTest3.psc


testquest.esp is in skyrim/data

http://www.mediafire.com/download/c6c1c7vw1chchf7/testquest.esp

User avatar
Manny(BAKE)
 
Posts: 3407
Joined: Thu Oct 25, 2007 9:14 am

Return to V - Skyrim