Anonymous user
Maze generation: Difference between revisions
Shorter first D version
(Updated D code) |
(Shorter first D version) |
||
Line 807:
=={{header|D}}==
{{trans|
<lang d>import std.stdio, std.
std.string, std.typecons;
void main() {
enum int
alias std.array.replicate R;
auto hWalls = new bool[][](W, H),▼
auto ver = array(map!((_){ return
(iota(h + 1)));
void
foreach
if (
if (p.y == y)
walk(p.x,
▲ ns = array(filter!((x){ return x != n; })(ns));
}
}
foreach (
}</lang>
Output example:
<pre>+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
| | | | |
+ +--+ + +--+--+ + +
| | | | |
+ + + + +--+ +--+--+ +
|
+ +--+
| | | | | | | | |
+
| | | | | | | | | | |
+ +--+ +--+ + +
| | | | |
+
| |
+ +--+ +--+
| | | | |
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+</pre>
===Alternative version ===
See [[Maze_solving#D]]
|