pub struct PartisanGameAnalyzer<G>{
game: G,
number: HashMap<G::State, i64>,
}Fields§
§game: G§number: HashMap<G::State, i64>Implementations§
Source§impl<G> PartisanGameAnalyzer<G>
impl<G> PartisanGameAnalyzer<G>
pub fn new(game: G) -> Self
Sourcepub fn eval(&mut self, s: &G::State) -> i64
pub fn eval(&mut self, s: &G::State) -> i64
Examples found in repository?
crates/competitive/src/algorithm/partisan_game.rs (line 85)
78 pub fn eval(&mut self, s: &G::State) -> i64 {
79 if let Some(n) = self.number.get(s).cloned() {
80 n
81 } else {
82 let lmax = self
83 .game
84 .next_left(s)
85 .map(|ns| self.eval(&ns))
86 .fold(i64::MIN, Ord::max);
87 let rmin = self
88 .game
89 .next_right(s)
90 .map(|ns| self.eval(&ns))
91 .fold(i64::MAX, Ord::min);
92 let res = Self::simple_number(lmax, rmin);
93 self.number.insert(s.clone(), res);
94 res
95 }
96 }Sourcefn simple_number(lmax: i64, rmin: i64) -> i64
fn simple_number(lmax: i64, rmin: i64) -> i64
Examples found in repository?
crates/competitive/src/algorithm/partisan_game.rs (line 92)
78 pub fn eval(&mut self, s: &G::State) -> i64 {
79 if let Some(n) = self.number.get(s).cloned() {
80 n
81 } else {
82 let lmax = self
83 .game
84 .next_left(s)
85 .map(|ns| self.eval(&ns))
86 .fold(i64::MIN, Ord::max);
87 let rmin = self
88 .game
89 .next_right(s)
90 .map(|ns| self.eval(&ns))
91 .fold(i64::MAX, Ord::min);
92 let res = Self::simple_number(lmax, rmin);
93 self.number.insert(s.clone(), res);
94 res
95 }
96 }Trait Implementations§
Source§impl<G> Clone for PartisanGameAnalyzer<G>
impl<G> Clone for PartisanGameAnalyzer<G>
Source§fn clone(&self) -> PartisanGameAnalyzer<G>
fn clone(&self) -> PartisanGameAnalyzer<G>
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 moreAuto Trait Implementations§
impl<G> Freeze for PartisanGameAnalyzer<G>where
G: Freeze,
impl<G> RefUnwindSafe for PartisanGameAnalyzer<G>
impl<G> Send for PartisanGameAnalyzer<G>
impl<G> Sync for PartisanGameAnalyzer<G>
impl<G> Unpin for PartisanGameAnalyzer<G>
impl<G> UnwindSafe for PartisanGameAnalyzer<G>
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