Struct alcibiades::Move [] [src]

pub struct Move(_);

Represents a move on the chessboard.

Move is a u64 number. It contains 3 types of information:

  1. Information about the played move itself.

  2. Information needed so as to be able to undo the move and restore the board into the exact same state as before.

  3. 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]

Creates a new instance.

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.

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.

Assigns a new score for the move.

Returns the assigned move score.

Returns the move type.

Returns the played piece type.

Castling is considered as king's move.

Returns the origin square of the played piece.

Returns the destination square for the played piece.

Returns the captured piece type.

If the previous move was a double pawn push, returns pushed pawn's file (a value between 0 and 7). Otherwise returns 8.

Returns the castling rights as they were before the move was played.

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.

Returns the least significant 16 bits of the raw move value.

Returns the algebraic notation of the move.

Examples: e2e4, e7e5, e1g1 (white short castling), e7e8q (for promotion).

Returns true if the move is a pawn advance or a capture, false otherwise.

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]

Formats the value using the given formatter.

impl Clone for Move
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl Copy for Move
[src]

impl PartialOrd for Move
[src]

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

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]

This method returns an Ordering between self and other. Read more

impl PartialEq for Move
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl Eq for Move
[src]

impl Display for Move
[src]

Formats the value using the given formatter. Read more