Ricardo SIGNES


Chess::960 - a Chess960 starting position generator


version 0.002


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



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.


  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]


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


Ricardo Signes <rjbs@cpan.org>


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.