Maze level generator

All development conversation and discussion takes place here

Moderator: Moderator

Post Reply
Message
Author
Freddybear
Wyrmic
Posts: 201
Joined: Wed Dec 06, 2006 6:58 pm
Location: Mordor, Ohio

Maze level generator

#1 Post by Freddybear »

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.
Attachments
maze_diff.txt
svn diff of maze.lua changes
(838 Bytes) Downloaded 229 times

Freddybear
Wyrmic
Posts: 201
Joined: Wed Dec 06, 2006 6:58 pm
Location: Mordor, Ohio

Re: Maze level generator

#2 Post by Freddybear »

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:
Image
Last edited by Freddybear on Tue Apr 19, 2011 3:13 am, edited 3 times in total.

Hedrachi
Uruivellas
Posts: 606
Joined: Tue May 11, 2010 8:58 pm
Location: Ore uh gun, USA

Re: Maze level generator

#3 Post by Hedrachi »

+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.
Having satellite internet is a lot like relying on the processes described in those RFC's for your internet. Except, instead of needing to worry about statues interrupting your connection, this time you worry about the weather. I have satellite internet. Fun, no?

lukep
Sher'Tul Godslayer
Posts: 1712
Joined: Mon Mar 14, 2011 10:32 am
Location: Canada

Re: Maze level generator

#4 Post by lukep »

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.
Some of my tools for helping make talents:
Melee Talent Creator
Annotated Talent Code (incomplete)

Freddybear
Wyrmic
Posts: 201
Joined: Wed Dec 06, 2006 6:58 pm
Location: Mordor, Ohio

Re: Maze level generator

#5 Post by Freddybear »

I found a Lua error when the "pickp" variable was set to zero. This should fix it up.
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

marvalis
Uruivellas
Posts: 683
Joined: Sun Sep 05, 2010 5:11 am

Re: Maze level generator

#6 Post by marvalis »

Looks like a good improvement, well done.

darkgod
Master of Eyal
Posts: 10750
Joined: Wed Jul 24, 2002 9:26 pm
Location: Angolwen
Contact:

Re: Maze level generator

#7 Post by darkgod »

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 ;)

Post Reply