From: Ian Jackson Date: Tue, 2 Mar 2021 22:48:23 +0000 (+0000) Subject: hidden recompute: wip X-Git-Tag: otter-0.4.0~250 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=4526c91c7a53b1050a5ab3a57bcb3c25a947b615;p=otter.git hidden recompute: wip Signed-off-by: Ian Jackson --- diff --git a/src/hidden.rs b/src/hidden.rs index 313cd180..55ca8fd6 100644 --- a/src/hidden.rs +++ b/src/hidden.rs @@ -714,40 +714,39 @@ mod recompute { r } pub fn mark_dirty(&mut self, occid: OccId) { self.outdated.insert(occid); } - pub fn implement(self, - _gplayers: &GPlayers, - _gpieces: &mut GPieces, - _goccults: &mut GameOccults, - _ipieces: &IPieces) -> Implemented { - dbg!(&self.outdated); // xxx - - // for each occultation - - // check to see if we have any views that are scrambled or - // displaced or invisible (we must do invisible too, so that - // when they reappear the ids have been permuted) - // - // err won't we always? - // - // choose a single permutation of the pieces in - // the Occultation::pieces map, and put the corresponding - // numbers in there - // - // somehow make the per player id maps permute the same way - // so we have all the pieces and their current visible piece ids - // get all the visible piece ids, sort them, then permute them - // then assign them like that - // - // when we are done, displaced sees - // but how do we send an update? - // when one is taken out of the hand, leaves a gap? - // does another one come in ? - // xxx - + pub fn implement(mut self, + gplayers: &GPlayers, + gpieces: &mut GPieces, + goccults: &mut GameOccults, + ipieces: &IPieces) -> Implemented { + for occid in self.outdated.drain() { + if let Some(occ) = goccults.occults.get_mut(occid) { + permute(occid, occ, gplayers, gpieces, ipieces); + } + } Implemented { } } } + + #[allow(unused_variables)] + fn permute(occid: OccId, + occ: &mut Occultation, + gplayers: &GPlayers, + gpieces: &mut GPieces, + ipieces: &IPieces) { + // We must permute for if we have any views that are scrambled + // or displaced obviously. For invisible too, so that when they + // reappear the ids have been permuted. And that's all the + // non-Visible views which an occultation ought to have at least + // one of... + // + // We choose a single permutation of the pieces in the + // Occultation::notches. + + + + } } use recompute::*;