UsedSituations

Trait UsedSituations 

Source
pub trait UsedSituations<T: Board> {
    // Required methods
    fn is(&self, board: &T) -> bool;
    fn add(&mut self, board: &T);
    fn remove(&mut self, board: &T);
}
Expand description

Container for used situations and similar to them

§Examples

use podch::{Board, UsedSituations};
let mut used = podch::HashUsedSituations::new();
let mut board = podch::VecBoard::new(2, 3);
assert!(!used.is(&board));  // By default, neither situation is marked used
used.add(&board);  // Mark "000\n000" as used
assert!(used.is(&board));
board.set(0, 1, podch::Stone::Light);
assert!(!used.is(&board));  // "020\n000" is not marked yet
used.add(&board);
board.set(0, 1, podch::Stone::None);
assert!(used.is(&board));  // "000\n000" is still marked
used.remove(&board);
assert!(!used.is(&board));  // no longer marked
board.set(1, 1, podch::Stone::Dark);
assert!(used.is(&board));  // "000\n010" is similar to "020\n000" that is marked
board.set(0, 1, podch::Stone::Dark);
assert!(!used.is(&board));  // "010\n010" is not similar to any used situation

Required Methods§

Source

fn is(&self, board: &T) -> bool

Check whether situation on board or any similar to it was used

Source

fn add(&mut self, board: &T)

Mark situation on board as used

Source

fn remove(&mut self, board: &T)

Mark situation on board as unused

Implementors§