#[repr(C)]
pub struct PartialPosition { /* private fields */ }
Expand description

A position with its move sequence omitted.

This data is insufficient for complete legality checking (such as repetition checking), but in most cases it suffices. If you need a complete legality checking, use Position.

TODO: describe exactly when a position is considered valid

Implementations

Returns an empty position.

Returns the starting position of shogi.

C interface of startpos.

Finds which player is to move.

Examples:

let mut pos = PartialPosition::startpos();
assert_eq!(pos.side_to_move(), Color::Black);
pos.make_move(Move::Normal { from: Square::SQ_7G, to: Square::SQ_7F, promote: false }).unwrap();
assert_eq!(pos.side_to_move(), Color::White);

Sets which player is to move.

Returns the Hand of a player.

Gives the reference to the hand of the specified player.

This function makes no guarantee about the consistency of the position. Users should have a good reason when using it. Exported for parsers.

Returns how many pieces of piece are in hand.

If piece is not a valid piece in hand, this method returns None.

Finds how many moves were made.

Sets how many moves are made. Returns whether this operation was successful. This operation succeeds iff ply != 0.

Returns the Piece on the designated Square.

Examples:

let pos = PartialPosition::startpos();
let black_rook = pos.piece_at(Square::SQ_2H);
assert_eq!(black_rook, Some(Piece::B_R));
let vacant = pos.piece_at(Square::SQ_3H);
assert_eq!(vacant, None);

C interface to PartialPosition::piece_at.

Place a piece on a square.

This function makes no guarantee about the consistency of the position. Users should have a good reason when using it. Exported for parsers.

Finds the subset of squares with a piece.

Since: 0.1.4

Finds the subset of squares with no pieces.

Finds the subset of squares where a piece of the specified player is placed.

Finds the subset of squares where a piece is placed.

Examples:

let pos = PartialPosition::startpos();
let black_rook = pos.piece_bitboard(Piece::B_R);
assert_eq!(black_rook, Bitboard::single(Square::SQ_2H));
let white_rook = pos.piece_bitboard(Piece::W_R);
assert_eq!(white_rook, Bitboard::single(Square::SQ_8B));

Finds the subset of squares where a PieceKind is placed.

Examples:

let pos = PartialPosition::startpos();
let rooks = pos.piece_kind_bitboard(PieceKind::Rook);
assert_eq!(rooks, Bitboard::single(Square::SQ_2H) | Bitboard::single(Square::SQ_8B));

Returns the last move, if it exists.

Examples:

use shogi_core::PartialPosition;
assert_eq!(PartialPosition::startpos().last_move(), None);

Returns the last move, if it exists.

Examples:

use shogi_core::PartialPosition;
assert_eq!(PartialPosition::startpos().last_compact_move(), None);

Makes a move. Note that this function will never check legality.

Returns Some(()) if the given move makes sense, i.e., moves a piece to another square or drops a piece on a vacant square.

If it returns None, it is guaranteed that self is not modified.

Makes a move. This function is a C-compatible counterpart of make_move. Note that this function will never check legality.

Returns true if the given move makes sense, i.e., moves a piece to another square or drops a piece on a vacant square.

If it returns false, it is guaranteed that self is not modified.

Write the current position in SFEN notation.

Available on crate feature alloc only.

Returns the SFEN representation of the current position.

Examples:

let pos = PartialPosition::startpos();
let s = pos.to_sfen_owned();
assert_eq!(
    s,
    "lnsgkgsnl/1r5b1/ppppppppp/9/9/9/PPPPPPPPP/1B5R1/LNSGKGSNL b - 1",
);

C interface of to_sfen.

Safety

This function writes to ptr at most 139 (= 129 + 1 + 1 + 1 + 0 + 1 + 5 + 1) bytes. Caller should ensure that ptr has enough space for that.

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

Returns the “default value” for a type. Read more

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. 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

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

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

Uses borrowed data to replace owned data, usually by cloning. 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.