| Chess-Play documentation | view source | Contained in the Chess-Play distribution. |
Chess::Play - Play chess games, calculate legal moves, use a search algorithm
use Chess::Play; my $cp = Chess::Play->new(); $cp->reset(); $cp->import_fen($fen) $cp->export_fen() $cp->set_piece_val($p_val, $n_val, $b_val, $r_val, $q_val); $cp->set_depth($depth) $cp->legal_moves() $cp->do_move($move) $cp->best_move() $cp->game_over(); $cp->print_board(); $cp->play() $cp->xboard_play([$custom_name])
This module allows to play a chess game using STDIN or the xboard graphical interface. Il also can calculate legal moves and uses the Alpha-Beta search algorithm to find the best move.
Create a new object to play chess.
Reset to the start position.
Set the position according to the FEN string $fen
Export the current position to the FEN string $fen
Change default values for pieces (the defaults are : 1, 3, 3, 5, 9)
Set the depth of the search algorithm (Alpha-Beta search).
Calculate the list of legal moves
execute a move (for instance "e2e4" or "a7a8q"). Return 1 if the move is legal, -1 if invalid, -2 if illegal
Tell if the game is over (Sheckmate, Stalemate, Insufficient Material, 50 moves rule). Threeway repetition is not supported in this version. Return "" if the game is not over.
Return the best move according to the search algorithm
Print an ASCII representation of the board
Play a chess game using STDIN
Play a chess game using xboard (only the basic xboad directives are supported). You can choose a name for your engine.
Giuliano Ippoliti, g1ul14n0 AT gmail
This is free software in the colloquial nice-guy sense of the word. Copyright (c) 2009, Giuliano Ippoliti. You may redistribute and/or modify it under the same terms as Perl itself.
perl(1).
| Chess-Play documentation | view source | Contained in the Chess-Play distribution. |