NAME
Chess::ChessKit A set of program to translate chess notations and analyses game by moves count
VERSION
Version 0.01
SYNOPSIS
ChessKit is composed of:
Move.pm : basic moves on an empty board.
Board.pm: functions for valid moves in a true game.
Trad::trad : functions to translate algebraic from one language to another one
Trad::dscrip :Translate english descriptive notation to long english algebraic
tradfromto.pl: standalone with a GUI (Tk/perl) using Trad::trad.
dscripdata.pl: example using Trad::dscrip and checks distribution
analizmov.pl: example using Chess::ChessKit:Board to find "best" moves according to TMN
note: TMN : Theoretical move number : it's the precise number of different valid moves at the disposal of the chess player having to play.
DESCRIPTION
ChessKit is a set of programs and packages to translate any chess notation into another one. As a consequence we have to provide software that can validate pieces (or pawns) moves.
About chess theory somebody states that advantage belongs to the player who has the bigger number of moves. So, to help to verify and pursue the idea,routines for that purpose have been developped.
EXPORT
all the functions below here.
FUNCTIONS inside Chess::ChessKit::Board
$gmv{$piece}(row=>$somerow, col =>$somecolumn, mov=>$ref_array_of_mov, color=>$piece) ;
return in $ref_array_of_mov all the moves that $piece written like in FEN (for example 'N' for White Knight, 'n' for Black Knight and so on). ($somerow,$somecolumn) are the coordinates of the starting square. color is again $piece because all the Whites are in upper case and blacks in lower case.
$bd->bestmove ; print a list of the best moves in the sense of TMN
$bd->boardcopy($new_board) ; copy the position of board $bd to the other board $new_board
$diag=$bd->can_castling(roq=>$roq , status=>$ref_status, out=>$out) ; check if a king can castle according to $ref_status (updated by has_moved). Also, verify the king is not checked. $roq=(KK|QK|kk|qk) where the first letter design the side and the second the king color. $out=('yes'|'no') if $out is to 'yes' a message indicates which pieces give a check. Default is 'no'. This function return 'yes' or 'no'.
$bd->cantake(who=>$piece, where=>$some_square) ; return 'no' if not possible or the type of the piece that can be taken.
$bd->castling(couleur=>$couleur, side=>$side, status=>$ref_status, out=>$out) execute castling if can_castling return 'yes' or die with diagnostic. Parameters can take the following values:
- $couleur=('White|'Black')
- $side(K|Q)
- $ref_status is the parameter already described above.
- $out=('yes'|'no') transmit this data to can_castling which print which piece give a check. Default is 'no'.
my ($cnt_white,$cnt_black)=$bd->chessmovcnt scan the board and return the count of the valid moves for both Blacks and Whites.
$bd->chessview print the board on screen.
$bd->deletepiece($location) delete the piece at location $location that are the algebraic coordinate of a square.
$piece=$bd->getpiece($location) retrieve the type of piece at board location $location
has_moved(status=>$ref_status, ini=>$ini)> set the status of Rook and king to know if they are always at there original place. So this function must be called after every moves. $ini=('y'|'no') if this parameter is set to 'y' the status is reset. The default option is of course 'no'.
bd->is_shaked(king=>$king, out=>$out) Diagnose if a king is checked by returning 'yes' or "" $out conditional parameter for printing the result if equal 'y'
$bd=Board->new(); create the objet $bd of class Board.
$bd->print print the position of pieces: location and type
$bd->put($piece,$location) place a piece $piece on the chessboard at $location
$bd->startgame(%set_position) initialize the chessboard with %set_position. Default without argument is the usual chessboard starting game.
$bd->valid(mov=>$set_of move, valid=>$set, piece=>$piece) intermediate validation of moves. Use datas obtained from %gmv : $set_of_move for $piece. It returns $set , the moves restricted to the true board.
$bd->vldmov(valid=>$set, piece=>$piece, row=>>$row, col=>>$col, recur=>>$control) Final validation of moves, where all the rules of chessgame are taken under consideration. Castling is separated and described before.
FUNCTIONS inside Chess::ChessKit::Trad
trad($outfile,$infile,$lang ,$lang2translate) translate an algebraic file or pgn given by $infile to $outfile where the source language is $lang and the output language is $lang2translate. They can take the following values: Czech|Danish|Dutch|English|Estonian|Finnish|French|German|Hungarian| Icelandic|Italian|Norwegian|Polish|Portuguese|Romanian|Spanish|Swedish
@array_of_moves=dscrip(mov=>$ref_array_of_moves , ini=>$ref_hash_position) Translate a descriptive notation with the following format:
where n is the move number followed by a dot then by the moves.(Note: last move of course could be only a white move) The input is a reference to the array of the moves in decriptive notation, An array in long algebraic notation is returned. If a $ref_hash_position is given then the global variable $bd is set to those values. By default, it is again the initial chess game position.
SEE ALSO
Chess::PGN,Chess::Board
AUTHOR
Charles Minc, <charles.minc@wanadoo.fr>
BUGS
Please report any bugs or feature requests to bug-mymove@rt.cpan.org
, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Chess::ChessKit::ChessKit. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
ACKNOWLEDGEMENTS
http://www.chess-theory.com//enthnct03_1_new_chess_theory_unfolding_game.htm
COPYRIGHT & LICENSE
Copyright 2005 Charles Minc, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.