Page 4 of 6

Re: Maze Thread

Posted: Sun Aug 18, 2013 4:34 pm
by Zer0
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.

Re: Maze Thread

Posted: Thu Aug 22, 2013 3:11 pm
by Germanunkol
Yay for the multilayer one! That looks pretty awesome :)

Re: Maze Thread

Posted: Thu Aug 22, 2013 8:06 pm
by Ref
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?

Re: Maze Thread

Posted: Thu Aug 22, 2013 8:13 pm
by Ranguna259
Yeah I was thinking the same thing

Re: Maze Thread

Posted: Fri Aug 23, 2013 2:07 pm
by Zer0
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.

Re: Maze Thread

Posted: Wed Apr 16, 2014 7:17 pm
by davisdude
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

Re: Maze Thread

Posted: Wed Apr 16, 2014 10:39 pm
by Ranguna259
Finally, a maze with a start and a finish :crazy:

Re: Maze Thread

Posted: Wed Apr 16, 2014 11:44 pm
by davisdude
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.

Re: Maze Thread

Posted: Thu Apr 17, 2014 5:26 am
by Germanunkol
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 :)

Re: Maze Thread

Posted: Thu Apr 17, 2014 1:13 pm
by Ranguna259
The first maze was easy, you should've chosen a better end :P
9jor7a12.jpg
9jor7a12.jpg (252.7 KiB) Viewed 5531 times