Generate random chess position: Difference between revisions

Content added Content deleted
m (shorter promotion test)
m (→‎{{header|Perl}}: simplify list 'quoting')
Line 642: Line 642:
=={{header|Perl}}==
=={{header|Perl}}==
{{trans|Perl 6}}
{{trans|Perl 6}}
<lang perl>use utf8;
<lang perl>use strict;
use warnings;
use feature 'say';
use feature 'say';
use utf8;
use List::AllUtils qw(shuffle any natatime);
use List::AllUtils <shuffle any natatime>;


sub pick1 { return @_[rand @_] }
sub pick1 { return @_[rand @_] }
Line 666: Line 668:


my ($row, @pp);
my ($row, @pp);
my @pieces = qw<p P n N b B r R q Q>;
my @pieces = <p P n N b B r R q Q>;
my @k = rand() < .5 ? qw(K k) : qw(k K);
my @k = rand() < .5 ? <K k> : <k K>;


for my $sq (0 .. 63) {
for my $sq (0 .. 63) {