pub struct TTable {
pub table: Vec<TTableBucket>,
}
Fields§
§table: Vec<TTableBucket>
Implementations§
source§impl TTable
impl TTable
sourcepub fn new(size: usize) -> Self
pub fn new(size: usize) -> Self
Constructs a new instance of TTable by allocating size
bytes of memory.
sourcepub fn add(
&self,
hash: u64,
score: i16,
best_move: Move,
depth: i8,
ply: u16,
type: u8,
age: u8
)
pub fn add( &self, hash: u64, score: i16, best_move: Move, depth: i8, ply: u16, type: u8, age: u8 )
Adds a new entry (storing the key, score
, best_move
, depth
, ply
, r#type
and age
) using hash
to calculate an index of the bucket.
Replacement strategy considers a few elements to optimize memory usage and prioritizes slots to replace as follows:
- empty slots or slots with the same key as the new entry
- slots with the smallest depth (if there are some old entries, prioritize them)
This function takes care of converting mate score
using passed ply
.
sourcepub fn get(&self, hash: u64, ply: u16) -> Option<TTableResult>
pub fn get(&self, hash: u64, ply: u16) -> Option<TTableResult>
Gets a wanted entry using hash
to calculate an index of the bucket. This function takes care of converting
mate score
using passed ply
. Returns None if entry does not exists or hash
is incompatible with the stored key.
sourcepub fn prefetch(&self, hash: u64)
pub fn prefetch(&self, hash: u64)
Prefetches an entry using hash
to calculate an index of the bucket. This function should be called early enough, so CPU has
enough time to transfer data from the memory into cache.
sourcepub fn get_best_move(&self, hash: u64) -> Option<Move>
pub fn get_best_move(&self, hash: u64) -> Option<Move>
Gets an entry’s best move using hash
to calculate an index of the bucket.
Returns None if entry does not exists or hash
is incompatible with the stored key.
sourcepub fn get_pv_line(&self, board: &mut Board, ply: i8) -> Vec<Move>
pub fn get_pv_line(&self, board: &mut Board, ply: i8) -> Vec<Move>
Retrieves PV line from the transposition table, using board
position and the current ply
.
sourcepub fn get_usage(&self, resolution: usize) -> f32
pub fn get_usage(&self, resolution: usize) -> f32
Calculates an approximate percentage usage of the table, based on the first resolution
entries.