pub trait RandomGenerator: Default {
// Required methods
fn next(&mut self) -> i32;
fn next_range(&mut self, from: i32, to: i32) -> i32;
// Provided method
fn get_random_from_vec<'a, K>(&mut self, vec: &'a Vec<K>) -> &'a K { ... }
}
Expand description
A trait for random number generation.
This allows for different random number generation strategies to be used with the MCTS search, which is particularly useful for testing and ensuring reproducibility.
Required Methods§
Sourcefn next_range(&mut self, from: i32, to: i32) -> i32
fn next_range(&mut self, from: i32, to: i32) -> i32
Returns a random i32
within the specified range (exclusive of to
).
Provided Methods§
Sourcefn get_random_from_vec<'a, K>(&mut self, vec: &'a Vec<K>) -> &'a K
fn get_random_from_vec<'a, K>(&mut self, vec: &'a Vec<K>) -> &'a K
Selects a random element from a vector.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.