Just another update

This commit is contained in:
Ingy döt Net 2015-02-20 00:35:01 -05:00
parent a25938f123
commit 00a190b0a6
6591 changed files with 94363 additions and 23227 deletions

View file

@ -1,4 +1,4 @@
void main() {
void main() @safe {
import std.stdio, std.algorithm, std.range, std.random;
enum uint w = 14, h = 10;
@ -6,9 +6,10 @@ void main() {
hor = iota(h + 1).map!(_ => ["+---"].replicate(w)).array,
ver = h.iota.map!(_ => ["| "].replicate(w) ~ "|").array;
void walk(in uint x, in uint y) /*nothrow*/ {
void walk(in uint x, in uint y) /*nothrow*/ @safe /*@nogc*/ {
vis[y][x] = true;
foreach (p; [[x-1,y], [x,y+1], [x+1,y], [x,y-1]].randomCover) {
//foreach (immutable p; [[x-1,y], [x,y+1], [x+1,y], [x,y-1]].randomCover) {
foreach (const p; [[x-1, y], [x, y+1], [x+1, y], [x, y-1]].randomCover) {
if (p[0] >= w || p[1] >= h || vis[p[1]][p[0]]) continue;
if (p[0] == x) hor[max(y, p[1])][x] = "+ ";
if (p[1] == y) ver[y][max(x, p[0])] = " ";
@ -17,5 +18,5 @@ void main() {
}
walk(uniform(0, w), uniform(0, h));
foreach (const a, const b; hor.zip(ver ~ []))
join(a ~ ["+\n"] ~ b).writeln;
join(a ~ "+\n" ~ b).writeln;
}