Maze generation: Difference between revisions

Content added Content deleted
No edit summary
(Tweaked first D version)
Line 961: Line 961:
alias Tuple!(uint,"x", uint,"y") P; // will wrap-around
alias Tuple!(uint,"x", uint,"y") P; // will wrap-around
auto d = [P(x-1, y), P(x, y+1), P(x+1, y), P(x, y-1)];
auto d = [P(x-1, y), P(x, y+1), P(x+1, y), P(x, y-1)];
randomShuffle(d);
d.randomShuffle();
foreach (p; d) {
foreach (p; d) {
if (p.x >= w || p.y >= h || vis[p.y][p.x]) continue;
if (p.x >= w || p.y >= h || vis[p.y][p.x]) continue;