Jump to content

Langton's ant: Difference between revisions

→‎{{header|Perl 6}}: move the defined test into the switch; we really use a quarter of the output area, not 50%
m (Different category name)
(→‎{{header|Perl 6}}: move the defined test into the switch; we really use a quarter of the output area, not 50%)
Line 1,358:
=={{header|Perl 6}}==
{{trans|Perl}}
In this version we use 4-bits-per-char graphics to shrink the output byto 50%a quarter the area of ASCII graphics.
<lang perl6>my @vecs = [1,0,1], [0,-1,1], [-1,0,1], [0,1,1];
constant @blocky = ' ▘▝▀▖▌▞▛▗▚▐▜▄▙▟█'.comb;
Line 1,365:
my @plane = [White xx $size] xx $size;
my ($x, $y) = $size/2, $size/2;
my $dir = (^@vecs).keys.pick;
my $moves = 0;
loop {
given (@plane[$x][$y] // last) {
when :!defined { last }
when White { $dir++; $_ = Black; }
when Black { $dir--; $_ = White; }
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.