pub struct SlotTable<K, M, S> { /* private fields */ }Expand description
A transposition table with a fixed number of slots, each holding at most one entry.
A key’s slot comes from the low bits of TableKey::slot. Storing always replaces what
the slot held, so memory stays fixed and recent positions win; a probe whose key differs
from the slot’s misses.
§Examples
use game_tree_search::{Hashed, Searcher, SlotTable, alpha_beta};
impl Hashed for Nim {
type Key = u64;
fn key(&self, &(stones, side): &Self::Position) -> u64 {
u64::from(stones) * 2 + u64::from(side == Side::Max)
}
}
// Many move orders lead to the same pile, so the table saves most of the work.
let mut searcher = Searcher::with_table(SlotTable::new(1024));
let remembered = searcher.search(&Nim, &(20, Side::Max), 20);
let plain = alpha_beta(&Nim, &(20, Side::Max), 20);
assert_eq!(remembered.score, plain.score);
assert!(remembered.stats.nodes < plain.stats.nodes / 10);Implementations§
Trait Implementations§
Auto Trait Implementations§
impl<K, M, S> Forget for SlotTable<K, M, S>
impl<K, M, S> Freeze for SlotTable<K, M, S>
impl<K, M, S> Move for SlotTable<K, M, S>
impl<K, M, S> RefUnwindSafe for SlotTable<K, M, S>
impl<K, M, S> Send for SlotTable<K, M, S>
impl<K, M, S> Sync for SlotTable<K, M, S>
impl<K, M, S> Unpin for SlotTable<K, M, S>
impl<K, M, S> UnsafeUnpin for SlotTable<K, M, S>
impl<K, M, S> UnwindSafe for SlotTable<K, M, S>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more