NAME
Chess::Opening::Book::Entry - An opening book entry.
SYNOPSIS
$book = Chess::Opening::Book::Polyglot->new('opening.bin');
$entry = $book->lookupFEN($fen) or die "position not found";
$total = $entry->weights;
$total = $entry->counts;
$fen = $entry->fen;
$moves = $entry->moves;
$entry->addMove(move => 'g1f3', count => 2304);
DESCRIPTION
An opening book represented by a Chess::Opening::Book consists of a list of positions represented as Chess::Opening::Book::Entry. Each entry is identified by the position as a FEN string (see "Positions" in Chess::Opening) and the sum of the weight of all moves.
METHODS
- new FILENAME
-
The constructor takes one single argument, the FILENAME of the opening book on disk. An exception is thrown if the file cannot be opened.
- lookupFEN FEN
-
Returns a Chess::Opening::Book::Entry for FEN or false. See "lookupFEN" in Chess::Opening::Book for more information
- moves
-
Returns a reference to a hash of Chess::Opening::Book::Move objects for this position. The keys are the moves in coordinate notation (see "Moves" in Chess::Opening) and the values are the associated objects.
- weights
-
Returns the sum of all weights of all moves for this position. This is best explained with an example.
Say the opening book contains two continuation moves Nc3 and Bc4 for a particular position. The move Nc3 was played successfully 300 times, and Bc4 was played successfully 100 times. 300 and 100 are the weights or counts for these move and the method
count()
for the entry, the position would then return 400, the sum of the weights of the two moves. The relative weights can then be calculated as300 / 400 = 0.75
and100 / 400 = 0.25
. - counts
-
An alias weights(), see above.
- fen
-
Returns the chess position in Forsyth-Edwards Notation FEN, see "Positions" in Chess::Opening.
- addMove move => MOVE, weight => WEIGHT
-
Adds a MOVE in coordinate notation with weight WEIGHT. You can use the named argument count as an alias for weight.
COPYRIGHT
Copyright (C) 2019 Guido Flohr <guido.flohr@cantanea.com>, all rights reserved.
SEE ALSO
Chess::Opening::Book, Chess::Opening::Book::Entry, Chess::Opening::Book::Move, perl(1)