I have made a small modification to the maze level generator in game/engines/default/engine/generator/map/Maze.lua. This modification makes mazes with many short branches and lots of dead ends. They might be a little more "fun" to explore.
A diff file is attached.
Maze level generator
Moderator: Moderator
-
- Wyrmic
- Posts: 201
- Joined: Wed Dec 06, 2006 6:58 pm
- Location: Mordor, Ohio
Maze level generator
- Attachments
-
- maze_diff.txt
- svn diff of maze.lua changes
- (838 Bytes) Downloaded 229 times
-
- Wyrmic
- Posts: 201
- Joined: Wed Dec 06, 2006 6:58 pm
- Location: Mordor, Ohio
Re: Maze level generator
Second pass of the maze mod is complete. This version randomly changes the degree of branching in the generated maze.
The diff for this mod is [moved - corrected patch is below].
A screenshot of one maze level is here:

The diff for this mod is [moved - corrected patch is below].
A screenshot of one maze level is here:

Last edited by Freddybear on Tue Apr 19, 2011 3:13 am, edited 3 times in total.
Re: Maze level generator
+1 Me likey... I don't particularly enjoy how in the default maze style you could explore for 50-75 tiles only to find that it's a big, long, confusing dead end, and spend the next 200 turns trying to remember which path leads back out again.
Re: Maze level generator
A great step in the right direction, although I would like more variety still, some levels being labyrinths ( zero branches), some incorporating loops, and some exactly like this.
-
- Wyrmic
- Posts: 201
- Joined: Wed Dec 06, 2006 6:58 pm
- Location: Mordor, Ohio
Re: Maze level generator
I found a Lua error when the "pickp" variable was set to zero. This should fix it up.
One last edit (I hope).
One last edit (I hope).
Code: Select all
Index: game/engines/default/engine/generator/map/Maze.lua
===================================================================
--- game/engines/default/engine/generator/map/Maze.lua (revision 3238)
+++ game/engines/default/engine/generator/map/Maze.lua (working copy)
@@ -39,7 +39,12 @@
local xpos, ypos = 1, 1
local moves = {{xpos,ypos}}
+ local pickp = rng.range(1,4)
while #moves > 0 do
+ local pickn = #moves - math.floor((rng.range(1,100000)/100001)^pickp * #moves)
+ local pick = moves[pickn]
+ xpos = pick[1]
+ ypos = pick[2]
local dir = {}
if self.map(xpos+2, ypos, Map.TERRAIN) == self.wall and xpos+2>0 and xpos+2<self.map.w-1 then
dir[#dir+1] = 6
@@ -75,9 +80,7 @@
end
table.insert(moves, {xpos, ypos})
else
- local back = table.remove(moves)
- xpos = back[1]
- ypos = back[2]
+ local back = table.remove(moves,pickn)
end
end
-- Always starts at 1, 1
Re: Maze level generator
Looks like a good improvement, well done.
Re: Maze level generator
Thanks!
[tome] joylove: You can't just release an expansion like one would release a Kraken XD
--
[tome] phantomfrettchen: your ability not to tease anyone is simply stunning
--
[tome] phantomfrettchen: your ability not to tease anyone is simply stunning
