Chess-Plisco
view release on metacpan or search on metacpan
lib/Chess/Plisco.pod view on Meta::CPAN
=item B<checkPseudoLegalMove(MOVE)>
Checks the legality of B<MOVE> (integer). The method only makes sense if you
pass it a move that was produced by B<pseudoLegalMoves>. Otherwise, the
behaviour is undefined.
The return value is falsy, if the legality check failed. Otherwise the modified
move is returned. The difference to the original move is that the captured
piece, the colour, and possible the en passant flag are set.
=item B<moveLegal(MOVE|NOTATION)>
Returns a truthy value, when the argument is a valid and legal move. The move
can be given either as an integer returned by L</parseMove> or as a string
that is accepted by L</parseMove>.
=item B<applyMove(MOVE|NOTATION)>
Parses the move given in B<NOTATION> and applies it to the position if the
move is valid and legal. Otherwise false is returned. You can also pass
the move as an integer as returned by L</parseMove>.
The method returns state information that can later be used to undo the move
and reset the position to the state it had before the move was applied.
Engines should use the method L</move> instead because it is faster.
=item B<unapplyMove(STATE)>
If B<STATE> is state information returned by L</applyMove>, takes back the
move that was given as an argument to L</applyMove>.
=item B<doMove(MOVE)>
Applies the move represented by the integer(!) B<MOVE> to the position. If
the move is legal, the method returns state information that can be used to
undo the move with L</undoMove>.
The method returns false, if the move is illegal. Note that this is not a
complete legality check but works only for those moves that
L</pseudoLegalMoves> has returned for the current position.
The method returns state information that can later be used to undo the move
and reset the position to the state it had before the move was applied.
=item B<undoMove(STATE)>
If B<STATE> is state information returned by L</doMove>, takes back the
move that was given as an argument to L</doMove>.
=item B<move(MOVE>)
Does the move B<MOVE> which must be legal because no legality check is
performed.
Unlike B<doMove()>, the method does not return state information that can be
used to later undo the move. The caller is responsible for that. A typical
pattern looks like this:
my @backup = @$position; # A shallow copy is sufficient.
foreach my $move ($position->legalMoves) {
my $state = $position->move($move);
# ... do something with $position.
@$position = @backup;
}
Consequently, there is no B<unmove()> method.
=item B<SEE(MOVE)>
Does a static exchange evaluation SEE for move B<MOVE>. B<MOVE> B<must> be
a capture, a promotion, a move giving check, or any combination of it. It
returns the raw material balance expected from the move.
The routine assumes, that after B<MOVE> had been made, all moves that re-capture
on the target field of B<MOVE> will be executed, starting with the least
valuable attacker of each side proceeding to the most valuable attacker. As
soon as a re-capture becomes disadvantageous, the sequence stops, and the
balance up to that point is returned.
Disadvantageous means that advancing to the "next round" would make the result
worse. For example a bishop would not normally capture a pawn that is
protected.
If you assign different values to bishops and knights by overriding
L</CP_KNIGHT_VALUE> and L</CP_BISHOP_VALUE> you may receive small values by
this routine, if the exchange of bishops and knights is involved. Depending
on your preferences you may ignore absolute values under a certain threshold,
for example 100 centipawns.
It should also be noted that the routine assumes that the values of pieces
follows this relation:
pawn E<lt> knight E<lt>= bishop E<lt> rook E<lt> queen (E<lt> king)
=back
=head2 Methods for Converting Locations
=over 4
=item B<squareToShift(SQUARE)>
Converts B<SQUARE> to a shift.
This is a class method.
=item B<squareToCoordinates(SQUARE)>
Converts B<SQUARE> to coordinates. It returns a list, not a an array reference.
Be sure to call it in array context!
This is a class method.
=item B<shiftToSquare(SHIFT)>
Converts B<SHIFT> to a square.
This is a class method.
=item B<shiftToCoordinates(SHIFT)>
Converts a shift to coordinates. It returns a list, not a an array reference.
Be sure to call it in array context!
( run in 2.489 seconds using v1.01-cache-2.11-cpan-75ffa21a3d4 )