Struct alcibiades::Move
[−]
[src]
pub struct Move(_);
Represents a move on the chessboard.
Move
is a u64
number. It contains 3 types of information:
Information about the played move itself.
Information needed so as to be able to undo the move and restore the board into the exact same state as before.
Move ordering info -- moves with higher move score are tried first.
Bits 0-15 contain the whole information about the move itself. This is called "move digest" and is laid out the following way:
15 0
+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | | | | | | | |
| Move | Origin square | Destination square | Aux |
| type | 6 bits | 6 bits | data |
| 2 bits| | | | | | | | | | | | | 2 bits|
| | | | | | | | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
There are 4 "move type"s: 0
) en-passant capture; 1
) pawn
promotion; 2
) castling; 3
) normal move. "Aux data" encodes the
type of the promoted piece if the move type is pawn promotion,
otherwise it is zero.
Bits 16-31 contain the information needed to undo the move:
31 16
+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | | | | | | | |
| | | Captured | Played | Castling | En-passant |
| 0 | 0 | piece | piece | rights | file |
| | | 3 bits | 3 bits | 4 bits | 4 bits |
| | | | | | | | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
If the previous move was a double pawn push, "en-passant file"
contains pushed pawn's file (a value between 0 and 7). Otherwise
it contains 8
. "Castling rights" holds the castling rights
before the move was played. When "Captured piece" is stored, its
bits are inverted, so that MVV-LVA (Most valuable victim -- least
valuable aggressor) move ordering is followed for moves that have
the same "score".
Bits 32-63 contain the "score" field, which is used to influence move ordering.
Methods
impl Move
[src]
fn new(move_type: MoveType,
orig_square: Square,
dest_square: Square,
aux_data: usize,
captured_piece: PieceType,
played_piece: PieceType,
castling_rights: CastlingRights,
enpassant_file: usize,
score: u32)
-> Move
orig_square: Square,
dest_square: Square,
aux_data: usize,
captured_piece: PieceType,
played_piece: PieceType,
castling_rights: CastlingRights,
enpassant_file: usize,
score: u32)
-> Move
Creates a new instance.
fn invalid() -> Move
Creates an invalid move instance.
The returned instance tries to mimic a legal move, but its
move digest equals MoveDigest::invalid()
. This is sometimes
useful in places where any move is required but no is
available.
fn piece_from_aux_data(pp_code: usize) -> PieceType
Decodes the promoted piece type from the raw value returned by
aux_data
.
The interpretation of the raw value is: 0
-- queen, 1
--
rook, 2
-- bishop, 3
-- knight.
fn set_score(&mut self, score: u32)
Assigns a new score for the move.
fn score(&self) -> u32
Returns the assigned move score.
fn move_type(&self) -> MoveType
Returns the move type.
fn played_piece(&self) -> PieceType
Returns the played piece type.
Castling is considered as king's move.
fn orig_square(&self) -> Square
Returns the origin square of the played piece.
fn dest_square(&self) -> Square
Returns the destination square for the played piece.
fn captured_piece(&self) -> PieceType
Returns the captured piece type.
fn enpassant_file(&self) -> usize
If the previous move was a double pawn push, returns pushed
pawn's file (a value between 0 and 7). Otherwise returns 8
.
fn castling_rights(&self) -> CastlingRights
Returns the castling rights as they were before the move was played.
fn aux_data(&self) -> usize
Returns a value between 0 and 3 representing the auxiliary data.
When the move type is pawn promotion, "aux data" encodes the promoted piece type. For all other move types "aux data" is zero.
fn digest(&self) -> MoveDigest
Returns the least significant 16 bits of the raw move value.
fn notation(&self) -> String
Returns the algebraic notation of the move.
Examples: e2e4
, e7e5
, e1g1
(white short castling),
e7e8q
(for promotion).
fn is_pawn_advance_or_capure(&self) -> bool
Returns true
if the move is a pawn advance or a capture,
false
otherwise.
fn is_null(&self) -> bool
Returns if the move is a null move.
"Null move" is a pseudo-move that changes nothing on the board except the side to move. It is sometimes useful to include a speculative null move in the search tree to achieve more aggressive pruning. Null moves are represented as king's moves for which the origin and destination squares are the same.
Trait Implementations
impl Debug for Move
[src]
impl Clone for Move
[src]
fn clone(&self) -> Move
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl Copy for Move
[src]
impl PartialOrd for Move
[src]
fn partial_cmp(&self, __arg_0: &Move) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, __arg_0: &Move) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, __arg_0: &Move) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, __arg_0: &Move) -> bool
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, __arg_0: &Move) -> bool
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl Ord for Move
[src]
fn cmp(&self, __arg_0: &Move) -> Ordering
This method returns an Ordering
between self
and other
. Read more
impl PartialEq for Move
[src]
fn eq(&self, __arg_0: &Move) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &Move) -> bool
This method tests for !=
.