NAME
Chess::960 - a Chess960 starting position generator
VERSION
version 0.003
OVERVIEW
Chess960 is a chess variant invented by Bobby Fischer, designed to somewhat reduce the value of memorization to play, while retaining key properties of the game such as castling and one bishop per color.
Chess::960 generates random starting positions for a Chess960 game.
use Chess::960;
my $fen = Chess::960->new->fen; # Forsyth-Edwards notation of position
my $pos = Chess::960->new->generate_position; # simple data structure
my $pos = Chess::960->new->generate_position(123); # get position by number
PERL VERSION
This library should run on perls released even a long time ago. It should work on any version of perl released in the last five years.
Although it may work on older versions of perl, no guarantee is made that the minimum required version will not be increased. The version may be increased for any reason, and there is no promise that patches will be accepted to lower the minimum required perl.
METHODS
new
The constructor for Chess::960 does not, at present, take any argument. In the future, it may take arguments to pick different mappings between positions and numbers.
generate_position
my $pos = $c960->generate_position($num);
This returns a starting description, described by a hash. If $num
is not provided, a random position will be returned. If a value for $num
that isn't an integer between 0 and 959 is provided, an exception will be raised.
Position 518 in the default mapping is the traditional chess starting position.
The returned hashref has two entries:
number - the number of the generated position
rank - an eight-element arrayref giving the pieces' positions
elements are characters in [BQNRK]
fen
This method returns a FEN-format string describing the complete starting position of the board. For example:
rnbbqkrn/pppppppp/8/8/8/8/PPPPPPPP/RNBBQKRN w KQkq - 0 1
AUTHOR
Ricardo Signes <cpan@semiotic.systems>
CONTRIBUTOR
Ricardo Signes <rjbs@semiotic.systems>
COPYRIGHT AND LICENSE
This software is copyright (c) 2014 by Ricardo Signes.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.