Maze Thread

Showcase your libraries, tools and other projects that help your fellow love users.
User avatar
Zer0
Citizen
Posts: 59
Joined: Sat Oct 06, 2012 9:55 am
Location: Sweden
Contact:

Re: Maze Thread

Post by Zer0 » Sun Aug 18, 2013 4:34 pm

Sorry for double posting.

Here is three more examples of mazes.

One with octagons, one with several layers and one with 10 different maze generation algorithms.
Attachments
OctagonMaze.love
Welcome to the OCTAGON.
(1.97 KiB) Downloaded 59 times
mutliLayer.love
Several layers
(2.53 KiB) Downloaded 62 times
JustMazes.love
10 maze algorithms
(9.25 KiB) Downloaded 73 times
If you can't fix it, Kill it with fire. ( Preferably before it lays eggs. )

Germanunkol
Party member
Posts: 711
Joined: Fri Jun 22, 2012 4:54 pm
Contact:

Re: Maze Thread

Post by Germanunkol » Thu Aug 22, 2013 3:11 pm

Yay for the multilayer one! That looks pretty awesome :)
trAInsported - Write AI to control your trains
Bandana (Dev blog) - Platformer featuring an awesome little ninja by Micha and me
GridCars - Our jam entry for LD31
Germanunkol.de

User avatar
Ref
Party member
Posts: 690
Joined: Wed May 02, 2012 11:05 pm

Re: Maze Thread

Post by Ref » Thu Aug 22, 2013 8:06 pm

You guys are creating some very nice wall paper but I was wondering if you had any scripts that would permit specifying a starting position (like lower left corner) and an objective position (like upper right corner or center screen) and maze grid size - something used for game scripts?

User avatar
Ranguna259
Party member
Posts: 911
Joined: Tue Jun 18, 2013 10:58 pm
Location: I'm right next to you

Re: Maze Thread

Post by Ranguna259 » Thu Aug 22, 2013 8:13 pm

Yeah I was thinking the same thing
LoveDebug- A library that will help you debug your game with an on-screen fully interactive lua console, you can even do code hotswapping :D

Check out my twitter.

User avatar
Zer0
Citizen
Posts: 59
Joined: Sat Oct 06, 2012 9:55 am
Location: Sweden
Contact:

Re: Maze Thread

Post by Zer0 » Fri Aug 23, 2013 2:07 pm

Ref wrote:You guys are creating some very nice wall paper but I was wondering if you had any scripts that would permit specifying a starting position (like lower left corner) and an objective position (like upper right corner or center screen) and maze grid size - something used for game scripts?
You could just slightly modify the recursive backtracker to have a higher chance of moving towards the finish point and have it start at the start point.
Or you could make your own recursive backtracker, it really isn't that hard.

Code: Select all

--Backtracker
function love.load()
    path={math.random(1,width),math.random(1,height)}
    map = newMap()
end

function love.update(dt)
    if #path > 0 then
        local x,y = path[#path][1],path[#path][2]
        local t = {}
        -- Add all the positions it CAN walk to from x and y
        if #t > 0 then -- It can walk somewhere
            local c = t[math.random(1,#t)]
            merge(x,y,c.x,c.y) -- Merge the points
            path[#path+1] = {c.x,c.y} -- Add the new point to the path
        else
            path[#path] = nil -- Remove the part in the path that could no walk anywhere
        end
    else
        print('DONE')
    end
end

function love.draw()
    love.graphics.draw( -- draw the map
end
thats what the actual algorithm looks like ( if not optimised ) but should not be too hard to make.

and as I have not seen anyone store maps the way I do here is a quick explanation:

using a texture atlas / tile sheet a table storing the different quads from 1 to 15. ( using 0 most of the time )
left,up,right,down = 1,2,4,8 -- power of two's
the first quad (quad[1])
is just quad[left] and therefore only goes left
and likewise quad[left+up+down] goes left, up and down
they can therefore be quickly added to a map where 0 is empty by doing
map[y][x] = map[y][x] + (left, up, right or down)
which is used instead of map[y][x].(left, up, right or down) = true

I use this method because:
1) its just the quad index stored in the map.
2) it take up less ram since less tables are needed.

the drawbacks are:
1) may be harder to get a hang on at first.

thats a quick summary of it, if you want a more complete explanation please tell me so.
If you can't fix it, Kill it with fire. ( Preferably before it lays eggs. )

davisdude
Party member
Posts: 1154
Joined: Sun Apr 28, 2013 3:29 am
Location: North Carolina

Re: Maze Thread

Post by davisdude » Wed Apr 16, 2014 7:17 pm

davisdude used Max Revive!
I figured I would try out making a maze to test my programming abilities.
You can check out my progress here.
It generates a 80*60 tile maze currently, but you can play around with the configurations if you want to.
Image
It takes around 3 minutes to fully complete.
Take a peek at the source code if you want. I tried to make it pretty readable, but I have a nasty habit of not commenting my code enough. :P
Attachments
Maze.love
(7.43 KiB) Downloaded 35 times
GitHub | MLib - Math and shape intersections library | Walt - Animation library | Brady - Camera library with parallax scrolling | Vim-love-docs - Help files and syntax coloring for Vim

User avatar
Ranguna259
Party member
Posts: 911
Joined: Tue Jun 18, 2013 10:58 pm
Location: I'm right next to you

Re: Maze Thread

Post by Ranguna259 » Wed Apr 16, 2014 10:39 pm

Finally, a maze with a start and a finish :crazy:
LoveDebug- A library that will help you debug your game with an on-screen fully interactive lua console, you can even do code hotswapping :D

Check out my twitter.

davisdude
Party member
Posts: 1154
Joined: Sun Apr 28, 2013 3:29 am
Location: North Carolina

Re: Maze Thread

Post by davisdude » Wed Apr 16, 2014 11:44 pm

Confession: I actually added the end with MS Paint. :(
I tried a 200 * 150 grid. Here are the results:
Image
Green is the start, yellow is the end. Working on making it automatically choose an end.
GitHub | MLib - Math and shape intersections library | Walt - Animation library | Brady - Camera library with parallax scrolling | Vim-love-docs - Help files and syntax coloring for Vim

Germanunkol
Party member
Posts: 711
Joined: Fri Jun 22, 2012 4:54 pm
Contact:

Re: Maze Thread

Post by Germanunkol » Thu Apr 17, 2014 5:26 am

Shame on you. Not for adding the end manually, but for using ms (paint)! :D

I would NOT want to have to find the end in that last maze... that's crazy :)
trAInsported - Write AI to control your trains
Bandana (Dev blog) - Platformer featuring an awesome little ninja by Micha and me
GridCars - Our jam entry for LD31
Germanunkol.de

User avatar
Ranguna259
Party member
Posts: 911
Joined: Tue Jun 18, 2013 10:58 pm
Location: I'm right next to you

Re: Maze Thread

Post by Ranguna259 » Thu Apr 17, 2014 1:13 pm

The first maze was easy, you should've chosen a better end :P
9jor7a12.jpg
9jor7a12.jpg (252.7 KiB) Viewed 1619 times
LoveDebug- A library that will help you debug your game with an on-screen fully interactive lua console, you can even do code hotswapping :D

Check out my twitter.

Post Reply

Who is online

Users browsing this forum: No registered users and 14 guests