pub struct OpeningBook {
pub map: HashMap<u64, i8>,
}
Expand description
A cache that stores pre-computed scores for opening game positions.
The book is stored as a HashMap
mapping a position’s unique key to its exact score.
A default opening book of depth 8 is embedded within the executable, providing fast
lookups without requiring any external files.
Fields§
§map: HashMap<u64, i8>
Implementations§
Source§impl OpeningBook
impl OpeningBook
Sourcepub fn new() -> OpeningBook
pub fn new() -> OpeningBook
Creates a new, empty opening book.
Sourcepub fn from_static_bytes(bytes: &'static [u8]) -> Result<OpeningBook, Error>
pub fn from_static_bytes(bytes: &'static [u8]) -> Result<OpeningBook, Error>
Creates an OpeningBook
by deserialising from a byte slice.
This is the key function that allows an opening book to be embedded within the executable.
Sourcepub fn get(&self, position: &Position) -> Option<i8>
pub fn get(&self, position: &Position) -> Option<i8>
Looks up a position’s score in the opening book.
Trait Implementations§
Source§impl Clone for OpeningBook
impl Clone for OpeningBook
Source§fn clone(&self) -> OpeningBook
fn clone(&self) -> OpeningBook
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for OpeningBook
impl Debug for OpeningBook
Source§impl Default for OpeningBook
Default constructor for the OpeningBook
struct.
impl Default for OpeningBook
Default constructor for the OpeningBook
struct.
Source§fn default() -> OpeningBook
fn default() -> OpeningBook
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for OpeningBook
impl<'de> Deserialize<'de> for OpeningBook
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for OpeningBook
impl RefUnwindSafe for OpeningBook
impl Send for OpeningBook
impl Sync for OpeningBook
impl Unpin for OpeningBook
impl UnwindSafe for OpeningBook
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more