Struct alcibiades::utils::MoveStack [] [src]

pub struct MoveStack { /* fields omitted */ }

Stores a list of moves for each position in a given line of play.

Examples:

let mut s = MoveStack::new();
assert_eq!(s.ply(), 0);
assert_eq!(s.list().len(), 0);
s.push(Move::invalid());
s.push(Move::invalid());
assert_eq!(s.list().len(), 2);
let first_move = s.pull_best();
assert_eq!(s.list().len(), 1);
s.save();
assert_eq!(s.ply(), 1);
assert_eq!(s.list().len(), 0);
s.restore();
assert_eq!(s.ply(), 0);
assert_eq!(s.list().len(), 1);
let second_move = s.pull_best();
assert_eq!(s.list().len(), 0);

Methods

impl MoveStack
[src]

Creates a new (empty) instance.

Saves the current move list and replaces it with an empty one.

This method can be called many times. At each call the current move list will be saved to the stack of lists that can later be restored. After calling save the new current move list will be empty.

Restores the last saved move list.

The current move list is lost.

Panics

Panics if there are no saved move lists left.

Returns the number of saved move lists.

The number of saved move lists starts at zero. It is incremented on each call to save, and decremented on each call to restore.

Clears the current move list, removing all moves from it.

Clears the current move list and deletes all saved move lists.

Appends a move to the end of the current move list.

Removes the last move from the current move list and returns it.

If the current move list is empty, None is returned.

Removes the move at given index from the current move list and returns it.

Move's slot is taken by the last move in the current list, and the last slot is discarded.

Panics

Panics if there is no move at the given index.

Removes a specific move from the current move list and returns it.

This method tries to find a move m for which m.digest() == move_digest. If such move is found, Some(m) is returned, move's slot is taken by the last move in the current list, and the last slot is discarded. If no such move is found, None is returned.

Removes the move with the highest value from the current move list and returns it.

Best move's slot is taken by the last move in the current list, and the last slot is discarded. None is returned if the current move list is empty.

Returns the current move list as a slice.

Returns the current move list as a mutable slice.

Trait Implementations

impl AddMove for MoveStack
[src]

Appends a move to the end of the current move list.