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@@@ @ @@@@@@@ @@@@@
@ @ @ @ @ @ @ @ @ @ @ @ @
@@@@@ @ @ @ @ @@@@@@@@@ @ @@@@@ @@@@@ @ @@@@@ @ @@@@@ @@@@@ @@@@@ @ @@@@@ @ @ @
@ @ @ @ @ @ @ @ @ @ @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
C:\lua>
It, uh, works, I guess. Kind of funny in that it both allows loops and creates inaccessabilities, even though that really isn't intentional...
Just for posterity, this is the output before I trashed the generation code:
C:\lua>lua5.1 maze.lua
*******************************************************************************
* * * * * * * * * * * *
**@ @ @ @ @ @ @*@ @ @ @ @*@*@*@*@ @ @ @ @*@ @*@*@*@*@ @ @ @*@*@*@*@*@ @ @ @ @**
* * * * * * * * * * * *
**@*@ @ @ @ @*@*@*@*@ @*@*@*@ @*@*@*@ @ @*@ @ @ @ @*@*@*@ @ @ @ @ @ @ @ @ @ @ *
* * * * * * * * * * * * *
**@*@ @ @ @*@*@*@*@*@*@*@ @*@*@*@*@*@*@ @ @ @ @*@*@*@*@ @ @ @ @ @ @ @*@*@*@*@**
* * * * * * * * * * * * * *
* @ @ @ @*@ @*@*@*@*@ @ @ @ @ @ @ @ @*@*@*@*@ @ @*@*@*@*@*@ @ @ @*@*@ @ @ @ @ *
* * * * * * * * * * * * * *
**@ @ @*@*@*@*@ @ @ @ @*@*@*@*@ @*@*@*@*@*@*@ @ @ @ @ @ @ @ @ @ @ @ @*@*@*@*@ *
* * * * * * * * * * * * * * *
* @ @ @ @ @*@ @*@*@ @ @ @ @ @ @*@*@*@*@ @ @ @*@ @*@*@*@*@*@*@ @*@*@ @*@ @ @ @**
* * * * * * * * * * * * * * * * * * * * * *
* @ @ @ @*@*@*@*@ @*@*@*@*@*@ @ @ @ @*@*@*@*@ @*@*@*@*@*@ @ @ @ @*@ @ @ @ @ @ *
* * * * * * * * * * * * *
* @ @ @ @ @ @*@*@*@ @ @ @*@*@*@*@ @ @ @*@*@*@ @ @ @*@*@*@*@ @ @ @ @ @*@ @ @ @ *
* * * * * * * * * * * * * * * * *
* @ @ @ @ @ @ @ @*@*@*@*@ @ @ @ @ @ @ @*@ @*@*@*@*@*@*@*@ @ @ @ @*@*@*@*@*@ @ *
* * * * * * * * * * * * * *
**@ @ @ @ @ @ @ @ @ @ @*@*@*@*@*@ @ @*@*@*@*@*@ @ @ @ @ @ @ @ @ @*@ @ @ @ @*@**
* * * * * * * * * * * * * * * * * * * *
*******************************************************************************
C:\lua>
It fundamentally will not work, so...
For refrence, snippets of code (mess of debug shit everywhere, beware):
for i = 0, 10000 do
local x = math.random(1, halfw) * 2 + 1;
local y = math.random(1, halfh) * 2 + 1;
local x2 = 0;
local y2 = 0;
local maxl = 2;
if math.random(0, 1) == 0 then
x2 = math.random(0, 1) * 2 - 1; -- fancy (i.e. stupid) way of getting -1 or 1
maxl = 4;
else
y2 = math.random(0, 1) * 2 - 1;
end;
-- print(string.format(" x %02d xx %02d y %02d yy %02d", x, x2, y, y2));
if m[y][x] == 0 then
m[y][x] = 2
for t = 1, maxl do
-- print(string.format(" x %02d xx %02d y %02d yy %02d", x, x + x2, y, y + y2));
if (x + x2) <= 1 or (y + y2) <= 1 or (x + x2) >= w or (y + y2) >= h then
maxl = -1;
elseif m[y + y2 * 2][x + x2 * 2] >= 1 then
-- m[y ][x ] = 1
m[y + y2][x + x2] = 1
m[y + y2][x + x2] = 1
x = x + x2 * 2;
y = y + y2 * 2;
else
maxl = -1; -- breaking out for lazy people
end;
end;
end;
end;