maze: apply additional branchiness fix from maze3d

We've tweaaked the chance though to make it look better though

Perhaps in the future we should add a setting for this?
This commit is contained in:
Starbeamrainbowlabs 2020-05-01 12:57:55 +01:00
parent 394f3ec4ef
commit a3a193cd68
No known key found for this signature in database
GPG Key ID: 1BE5172E637709C2

@ -54,10 +54,11 @@ function generate_maze(seed, width, height)
if cx + 2 < width and world[cy][cx + 2] == "#" then
directions = directions .. "r"
end
--print("radar output: '" .. directions .. "' (length: " .. #directions .. "), curnode: " .. curnode)
local shift_attention = math.random(0, 9)
if #directions > 0 then
-- we still have somewhere that we can go
--print("This node is not a dead end yet.")
local curdirnum = math.random(1, #directions)
local curdir = string.sub(directions, curdirnum, curdirnum)
if curdir == "u" then
@ -82,19 +83,17 @@ function generate_maze(seed, width, height)
else
--print("The node at " .. curnode .. " is a dead end.")
table.remove(nodes, curnode)
-- No need to do anything else here, since #directions == 0 will cause a teleport - see below
end
if #directions == 0 or shift_attention <= 1 then
if #nodes > 0 then
--print("performing teleport.");
curnode = math.random(1, #nodes)
--print("New node: " .. curnode)
-- print("Nodes table: ")
-- print_r(nodes)
cx = nodes[curnode]["x"]
cy = nodes[curnode]["y"]
else
--print("Maze generation complete, no teleportation necessary.")
end
end
--printspace(world, width, height)
end
return world