Maze generation: Difference between revisions

m
Wider maze cells in D entry
(Updated D entry)
m (Wider maze cells in D entry)
Line 1,043:
 
void main() {
enum int w = 1614, h = 810;
auto vis = new bool[][](h, w),
hor = iota(h + 1).map!(_ => R(["+---"], w))().array(),
ver = iota(h).map!(_ => R(["| "], w) ~ "|")().array();
 
void walk(in int x, in int y) /*nothrow*/ {
Line 1,054:
foreach (p; d.randomCover(Random(unpredictableSeed))) {
if (p.x >= w || p.y >= h || vis[p.y][p.x]) continue;
if (p.x == x) hor[max(y, p.y)][x] = "+ ";
if (p.y == y) ver[y][max(x, p.x)] = " ";
walk(p.tupleof);
}
Line 1,064:
}</lang>
{{out}}
<pre>+--+--+--+--+---+---+---+---+---+---+---+---+---+---+---+---+
| | | | | |
+ +--+ + +---+---+ + + +--+ +---+ + +---+---+---+ + +
| | | | | | | | | | | | | |
+ ---+ + + ---+--+ -+---+---+ +---+---+ +---+ +---+ + +---+
| | | | | | | | | |
+ +---+ +---+---+ +--+-- + +---+ +---+---+ +---+--+ -+
| | | | | | | | | | | |
+---+ +-- + +--+-- + + +---+---+---+ + +--+--+--+ + +
| | | | | | | | | | | | |
+ +--+ +---+ + + +---+---+ + +---+---+ ---+ +---+ +
| | | | | | | | | |
+--+ +--+--+---+ + +---+---+---+---+---+ +---+---+ + +--+
| | | | | | | | | | |
+ +---+ +-- +--+--+---+ + +---+ + + +---+---+ + +
| | | | | | | | |
+-- +--+--+--+--+--+--+-- + +---+-- +--+--+ + + +--+--+--+--+</pre>
| | | | | | | | |
+ + +---+---+---+---+ +---+ + +---+---+ + +
| | | |
+---+---+---+---+---+---+---+---+---+---+---+---+---+---+</pre>
===Alternative version ===
See [[Maze_solving#D]]