Maze generation: Difference between revisions
→{{header|Lua}}
mNo edit summary |
Johnicholas (talk | contribs) |
||
Line 3,328:
-- Fisher-Yates shuffle from http://santos.nfshost.com/shuffling.html
function shuffle(t)
end
-- builds a width-by-height grid of
function initialize_grid(w, h)
end
-- average of a and b
function avg(a, b)
end
dirs = {
}
function make_maze(w, h)
▲ {x = x, y = y-2}, -- north
▲ {x = x+2, y = y}, -- east
local xx = x + dirs[dirnum].x
▲ {x = x-2, y = y}, -- west
local yy = y + dirs[dirnum].y
▲ {x = x, y = y+2}, -- south
▲ shuffle(d)
▲ for i, dir in ipairs(d) do
end
▲ if map[yy] == nil then
▲ map[avg(y, yy)][x] = true
▲ end
▲ walk(xx, yy)
▲ end
end
|