Maze generation: Difference between revisions
Content added Content deleted
(Simpler D version) |
(More readable D code) |
||
Line 814: | Line 814: | ||
enum int w = 16, h = 8; |
enum int w = 16, h = 8; |
||
alias std.array.replicate R; |
alias std.array.replicate R; |
||
auto |
auto vis = new bool[][](h, w), |
||
hor = array(map!((_){ return R(["+--"], w); })(iota(h + 1))), |
|||
ver = array(map!((_){ return R(["| "], w) ~ "|"; })(iota(h))); |
|||
void walk(in int x, in int y) /*nothrow*/ { |
void walk(in int x, in int y) /*nothrow*/ { |
||
Line 830: | Line 830: | ||
} |
} |
||
} |
} |
||
walk(uniform(0, w), uniform(0, h)); |
walk(uniform(0, w), uniform(0, h)); |
||
foreach (a, b; lockstep(hor, ver ~ [])) |
foreach (a, b; lockstep(hor, ver ~ [])) |