Langton's ant: Difference between revisions
Content added Content deleted
(→{{header|Perl 6}}: shrink output by 50%) |
|||
Line 1,357:
=={{header|Perl 6}}==
{{trans|Perl}}
In this version we use 4-bits-per-char graphics to shrink the output by 50%.
<lang perl6>my @dirs = [1,0], [0,-1], [-1,0], [0,1];
constant @char = ' ▘▝▀▖▌▞▛▗▚▐▜▄▙▟█'.comb;
my ($x, $y) = $size/2, $size/2;
my $dir =
loop (my $move = 0; 0 <= $x < $size
if @plane[$x][$y] = 1 - @plane[$x][$y] {
$dir = ($dir + 1) % @dirs;
} else {
$dir = ($dir - 1) % @dirs;
}
$x += @dirs[$dir][0];
$y += @dirs[$dir][1];
}
for 0,2,4 ...^ $size - 2 -> $
for
+ 2 * @plane[$x][$y+1]
}▼
+ 4 * @plane[$x+1][$y]
print "\n";▼
+ 8 * @plane[$x+1][$y+1];
print @char[$sum];
▲ }
▲ print "\n";
}</lang>
{{out}}
<pre>Out of bounds after 11669 moves at (-1, 26)
▄▚▚
▟▟▜▟▚
▜▀▚▌▟▚
▜▘▗▌▟▚
▜▘▗▌▟▚
▜▘▗▌▟▚
▜▘▗▌▟▚
▜▘▗▌▟▚
▜▘▗▌▟▚
▜▘▗▌▟▚
▜▘▗▌▟▚
▜▘▗▌▟▚
▜▘▗▌▟▚
▜▘▗▌▟▚
▜▘▗▌▟▚
▜▘▗▌▟▚ ▄
▜▘▗▌▟▘▟▘▗
▞▀▚ ▜▘▗▌▄▙▝▜
▐█ ▌▄▘▘▗▗▞▐▚▌
▌▖▝ ▐▚▙▙ ▖▀▖
▐▄▝█▀▖▄▗▗▗▀▐▛▛▙
▞▚▝▟██▜▞ ▞▗▜▌ ▞▘▌
▐▗▄▌▙▜▐▄▛▀▜▞▜▛▛▄▐
▘▗▝▜▚▖▌▟▞▛▜▌▜▖ █▌
▄▄ ▄▜▛▜▙▖▟▗▛▟▘▌ ▌
▟▖ ▘▘▄▛▌▛▟█▖ ▚▜▀ ▌
▘▘ █▚▛▜▟▌▘▗█▞▛▞▌ ▌
▐▖ ▙▐▙▗█▌▐▀ ▟▛ ▄ ▌
▟▙▚▛▀▄▗▟▖▐▗▘▛▐▀▟▌ ▌
▘▀▞▛▗▘▘█▐▞▗▗▝▟▖▄▝▝
▗▜▞▖▗▘▝█▜▞▖▗▙ ▝ ▙▌
▟▞▖▟▄▌▟▄▙▐█▗▟▙▟▚▗▞
▘▌▚▖▝▛▀ ▐▘▞█▀▟▛█▖
▄ ▝▛▚ ▀▜▙▜▜▀▜▚▄▘▙▖
▟▖▘▐▜▌▛▄▟▛▝▌ ▜▘▛▗▖▟▌
▘▀█▙▙▚▄▛▗▛▖ ▞▗▖▚▗▚▞
▜ ▖▄▙▛▚▀▗▜▛ ▞▗▝▛
▞▌▜▌█▀▀▘▖ ▙ ▌▀
▐▗▌█▛ ▀▚▞▚▞
▜▖
</pre>
=={{header|PicoLisp}}==
|