Page 1 of 2

[Mod] Maze [0.5.5] [maze]

Posted: Sat Aug 18, 2012 20:17
by Echo
Get lost! This will generate a random maze near your position. Will you find the exit?
Hint: The map is printed out in the console.

Use the chat-command

Code: Select all

/maze <size_x> <size_y> <#floors> <material_floor> <material_wall> <material_ceiling>
Example:

Code: Select all

/maze
gives you 20 x 20 x 3 maze with cobble walls, floor and ceiling

Code: Select all

/maze 30 50 1 default:dirt default:stone air
gives you 30 x 50 x 1 maze with dirt floor, stone walls, without ceiling

License
Code: WTFPL

Mod dependencies
default

Download
0.5.6 maze_0_5_6.zip
0.5.5 maze_0_5_5.zip
0.5.1 maze_0_5_1.zip
0.5 maze_0_5.zip
0.4.1 maze_0_4_1.zip
0.4 maze_0_4.zip
0.3 maze_0_3.zip
0.2.2 maze_0_2_2.zip
0.2.1 maze_0_2_1.zip
0.2 maze_0_2.zip
0.1 maze_0_1.zip

Image
default:stone - floor, default:cobble - walls and air-ceiling.

Version History
  • 0.5.5 added 20% partial braid maze (loops, harder to get through maze), small bug fixed placing the treasure
  • 0.5.1 bug fixed with "closer"-stone on exit
  • 0.5 find the treasure, added some torches, when you enter the maze the entrance closes (now you have to find the exit)
  • 0.4.1 fixed rounding error when coordinates jump from positive to negative, if exit is underground dig a hole to surface
  • 0.4 mazes are now 3D (3 floors by default), mazes are now really random (forgot randomseed), check if chosen material exists else fallback to default:cobble
  • 0.3 maze is generated in view direction of player, the exit of the maze is now always reachable, the entrance is right in front of you (middle of maze_size_y), default size is now 20 x 20
  • 0.2.2 nicer walls (no more "over-edge" walls, as in the screenshot, where light could shine through), therefore faster generation
  • 0.2.1 code cleanup
  • 0.2 choose material for wall, bottom, ceiling (optional)
  • 0.1 first release
ToDo
  • some bigger rooms in the maze, not just corridors
Edit: added word "license" for sfan5s squealer-script

Posted: Sat Aug 18, 2012 21:45
by sfan5
Nice!

Posted: Sun Aug 19, 2012 03:12
by cornernote
this is just a-MAZE-ing =)

Posted: Sun Aug 19, 2012 07:28
by Blackthorne
Could you perhaps make a variant that creates mazes out of leaves/hedges? It'd be perfect for my Victorian manor gardens.

+1

Posted: Sun Aug 19, 2012 09:14
by pagliaccio
screen?

Posted: Sun Aug 19, 2012 09:30
by VanessaE
Could you also add a screenshot?

Posted: Sun Aug 19, 2012 09:51
by Echo
Blackthorne wrote:Could you perhaps make a variant that creates mazes out of leaves/hedges? It'd be perfect for my Victorian manor gardens.

+1
added your wish to my todos. Then you probably don't want a ceiling.

[Edit] realized your wish, except that leaves will disappear without a tree next to it... so build your floor out of default:tree or create a mod with a non-disappearing hedge-node.

Posted: Sun Aug 19, 2012 15:59
by NakedFury
Tried it yesterday.

Game runs out of lua memory if you try to make a 10000x10000 or 7kx7k maze.

I made a 10x10 maze, then without moving I ran the code again for a 15x15 maze it replace the old 10x10 maze.

Im gonna try to find where the run out of memory bug starts.

Edit: Ok just finished a very long construction of a 1kx1k long maze. IT took some time but it finally finished.
Gonna test 2kx2k later.

Posted: Sun Aug 19, 2012 16:20
by Echo
Ok, I don't know the data-structure of LUA, but assuming that a number (LUA doesn't seems to have a byte or a integer type) needs 4 Bytes RAM.

Then we have 7000 * 7000 = 187MB just for the maze, then there is an array with coordinates for the creation-way through the maze with about another 150 MB.

7000 x 7000 is really big. Want to get lost forever? ;-)

Posted: Sun Aug 19, 2012 16:25
by NakedFury
Servererror: Luaerror: error: not enough memory

That is the complete error message

Posted: Sun Aug 19, 2012 16:52
by Echo
For the array, representing the maze, I will switch to boolean instead of number. That will save a lot of memory.

Posted: Mon Aug 20, 2012 17:23
by Echo
Tested 3000 x 3000 maze, it takes a long time but works now.

And you have to make sure your world is already generated that far. If not, the terrain builder will come and generate the landscape over/through the maze.

Posted: Tue Aug 21, 2012 02:52
by NakedFury
Yesterday my debug file got to weight a wooping 500 or more mb.

Posted: Tue Aug 21, 2012 03:11
by Bas080
cornernote wrote:this is just a-MAZE-ing =)
I wanted to make that same remark because it IS!

I like the ToDo list. 3d Mazes. I like seeing more of these ideas where you have this game-inception. Minetest is great for games in a game.

Posted: Tue Aug 21, 2012 05:10
by Blackthorne
I love watching things evolve. Only yesterday, this mod was at 0.1. now it's already gone through several more releases in a single DAY. That's pretty awesome.

Posted: Tue Aug 21, 2012 08:55
by Echo
thanx alot

As I don't know how much time I can invest in developing my mods, I try to publish even the smaller steps. And we're far away from version 1.0 ;-)
Ok, next will be 3D-mazes, this will take a little bit longer...

Posted: Wed Aug 22, 2012 11:07
by Echo
Tadaaa, 3D - mazes with ladders between the floors. It's really hard to keep orientation even in small mazes.

Posted: Fri Aug 24, 2012 12:38
by Echo
Fixed bug when coordinates jump from positive to negative. When the exit is underground, a ladder will lead up to surface.

Posted: Wed Aug 29, 2012 17:31
by Echo
Update:

Posted: Sun Sep 02, 2012 10:07
by Echo
Update:
  • added 20% partial braid maze, about 20% of the dead end walls are broken to build loops. So it's harder to find your way through the maze.
  • fixed small bug placing the treasure
  • some more comments, especially for me...

Posted: Wed Sep 05, 2012 10:52
by Echo
@GloopMaster: I changed the licence to WTFPL. So feel free to do what you want to.

I had something different in mind. I thought about evolving this mod to a new mod called: PacMan!
Rules:
Enter the maze, the mobs will hunt you through the maze.
You can find certain nodes in the maze which will make you a "hunter", so the mobs flee from you for some time (playing hunter-music in this time?). When you kill a fleeing mob you get a treasure. Killling a "hunting" mob will be much harder and will get you nothing.
The exit will only open, when all mobs are killed.

Posted: Wed Sep 05, 2012 12:57
by Echo
GloopMaster wrote:Well, i mean because i have not the slightest idea where to start to make the mazes on mapgen. :)
Haven't done before, too. But when you look at celerons mobs-mod [http://c55.me/random/2012-07/mobs.tar.gz], his dungeons are just added after a new chunk has been generated.

Code: Select all

minetest.register_on_generated(function(minp, maxp, seed)
Perhaps he reads this topic and uses the algorithm to create better dungeons... :-)

Posted: Mon Sep 24, 2012 07:12
by cornernote
[request]

can you make a craftable node, when you put it down:

a) it generates a maze with a fixed size
or
b) can you make a formspec (like a chest) so that you put the options into it, then click go and the maze is created

that way we can see mazes in public servers

edit: this is now done, as part of deploy nodes

Posted: Thu Sep 27, 2012 07:37
by cornernote
would you mind if this was added to worldedit? that way i can add it to the worldedit gui, and we will have a gui for making mazes! =)

Posted: Thu Sep 27, 2012 08:20
by Echo
WTFPL
So do whatever you want to. Remove the "closer-stone" and/or the "treasure-chest", make it braid or not. The algorithm wasn't invented by me, I read http://www.astrolog.org/labyrnth/algrithm.htm and tried to bring that to lua code.

Take it, change it, write your name over it. You have my blessing. :-)

Btw: Any problem understanding the code (although I commented very much for my standards), I try to explain in advance:

1. create an table/array in size of the maze with all set to "true" -> walls
2. choose a random start-point and check all possible directions (wall exists) and choose one of it randomly. That's your new position. If there is no more direction possible (dead-end), walk back the way you came from until you find a position where an other direction is possible (make junction).
3. Repeat step 2 until you had to go back to your start-point.
4. Dig a way in the maze from the opposite side of the maze until you reach a corridor. That's the exit.

Additions:
Floors: Added a check for up-/downstairs for possible directions in step 2 (and mark them to place ladders later)
Torches: Illuminate the corridors or let the player do the work (I found it more confusing for the player if there are already torches, because else you place a torch always on your right side and when you find your torch again, you know you were there before and you know from which direction you came from)
Braid-maze: Mark all dead-ends and try to open some after the creation is done. This prevents the "always keep right" method to find the way through the maze)
Treasure: Place a chest in a dead-end (and don't open that dead-end for braid-maze)
Closer-stone: A node on the start-point and the exit, that closes behind the player when he moves over it. So he has to find the exit.