Maze generation: Difference between revisions

Updated D code
(Go solution)
(Updated D code)
Line 817:
alias Tuple!(uint,"x", uint,"y") P;
 
void visit(in int x, in int y) {
seen[x][y] = true;
P[] D = [P(x-1,y), P(x+1,y), P(x,y-1), P(x,y+1)];
P[] ns = array(filter!((p){ return p.x < W && p.y < H; })(D));
while (ns.length) {
Pimmutable n = ns[uniform(0, ns.length$)];
if (!seen[n.x][n.y]) {
if (x != n.x) ? hWalls[min(x, n.x)][y] = true;:
else vWalls[x][min(y, n.y)]) = true;
visit(n.tupleof);
}
Anonymous user