Struct chess_engine::Position[][src]

pub struct Position { /* fields omitted */ }

Implementations

Return the starting position for a given color’s king.

Return the starting position for a given color’s queen.

Create a Position from its respective row or column number. The row and column numbers can be any of 0, 1, 2, 3, 4, 5, 6, or 7.

Examples:

  • A1 = Position::new(0, 0)
  • A8 = Position::new(7, 0)
  • H1 = Position::new(0, 7)
  • H8 = Position::new(7, 7)

Parse a position from PGN. This simply just supports positions like e4 and D8.

Is this position a valid spot on the board?

Is this position NOT a valid spot on the board?

Get the row number of the position. This can be any of 0, 1, 2, 3, 4, 5, 6, or 7.

Is this position diagonal to another position?

Is this position orthogonal to another position?

Is this position adjacent to another position?

Adjacent positions have either:

  1. A diagonal distance of one from each other
  2. An orthogonal distance of one from each other

Is this position beneath another position on the board? Pieces “beneath” other pieces on the board have lower ranks.

So, for example, A7 is below A8.

Is this position above another position on the board? Pieces “above” other pieces on the board have higher ranks.

So, for example, A8 is above A8.

Is this position left of another position on the board? Pieces “left of” other pieces on the board have a lower lexigraphical column character.

So, for example, A8 is left of B8.

Is this position right of another position on the board? Pieces “right of” other pieces on the board have a higher lexigraphical column character.

So, for example, B8 is right of A8.

Get the position directly below this position.

IMPORTANT NOTE: This will NOT check for positions off of the board! You could easily get an invalid position if you do not check with the is_on_board method!

Get the position directly above this position.

IMPORTANT NOTE: This will NOT check for positions off of the board! You could easily get an invalid position if you do not check with the is_on_board method!

Get the next square upwards from a respective player’s pawn.

IMPORTANT NOTE: This will NOT check for positions off of the board! You could easily get an invalid position if you do not check with the is_on_board method!

Get the next square backwards from a respective player’s pawn.

IMPORTANT NOTE: This will NOT check for positions off of the board! You could easily get an invalid position if you do not check with the is_on_board method!

Get the position directly left of this position.

IMPORTANT NOTE: This will NOT check for positions off of the board! You could easily get an invalid position if you do not check with the is_on_board method!

Get the position directly right of this position.

IMPORTANT NOTE: This will NOT check for positions off of the board! You could easily get an invalid position if you do not check with the is_on_board method!

Is this pawn on the starting rank for the respective player?

Is this the starting position of the kingside rook?

Is this the starting position of the queenside rook?

Get the list of positions from this position to another position, moving diagonally.

This does not include the from position, and includes the to position.

Get the list of positions from this position to another position, moving orthogonally.

This does not include the from position, and includes the to position.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Formats the value using the given formatter. Read more

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

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

Restrict a value to a certain interval. Read more

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

This method tests for !=.

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

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.