From 185b53246fa2b2cb88bc7c61eed6a9371897e460 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sun, 12 Jun 2022 23:00:23 +0100 Subject: [PATCH] hidden: Note everything as occulted, even the unoccultable They now have a `passive`, and an occid, and so on. But of course they don't look any different. They end up treated as IOI::Distinct, so in unnotched. The overall effect is simply on counting: now they are counted. Signed-off-by: Ian Jackson --- src/hidden.rs | 15 +++++---------- src/vpid.rs | 7 ++----- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/src/hidden.rs b/src/hidden.rs index f1389081..7f292a33 100644 --- a/src/hidden.rs +++ b/src/hidden.rs @@ -435,9 +435,8 @@ impl IPiece { match y { Some(y) => Left(y), None => Right({ - let occilk = self.occilk.as_ref() - .ok_or_else(|| internal_logic_error(format!( - "occulted non-occultable {:?}", self)))?; + if_let!{ Some(occilk) = self.occilk.as_ref(); + else return Ok(Left(ShowUnocculted::new_visible())); } let occ_data = ioccults.ilks.from_iilk(occilk) .ok_or_else(|| internal_logic_error(format!( "occulted ilk vanished {:?} {:?}", self, occilk)))?; @@ -588,10 +587,6 @@ pub fn recalculate_occultation_general< // prevent occulting pieces being occulted // (also prevents reflexive occultation) return None - } else if ipc.occilk.is_none() { - // if we cannot make it look identical to the others, we - // cannot occult it beause we can't hide its identity - return None } else if occ.in_region(gpc.pos) { Some(Occulted { occid, occ }) } else { @@ -731,14 +726,14 @@ pub fn recalculate_occultation_general< if let Some(occid) = occulteds.new; let zg = gen.next(); let occ = occultation(goccults, occid); - if let Some(ilk) = wants!( ipc.occilk.as_ref() ); + let ilk = ipc.occilk.as_ref(); then { let permute_notch = match ilk { - IOI::Distinct(_) => { + Some(IOI::Distinct(_)) | None => { occ.unnotched.insert(piece); None }, - IOI::Mix(ilk) => { + Some(IOI::Mix(ilk)) => { if_chain!{ if occ.notches.is_empty(); if let Some(ilk) = wants!( ioccults.ilks.get(ilk) ); diff --git a/src/vpid.rs b/src/vpid.rs index 10ca8e32..2e3dd1a1 100644 --- a/src/vpid.rs +++ b/src/vpid.rs @@ -280,7 +280,7 @@ fn exhaustive() { st.recurse(); } -pub fn permute(occid: OccId, +pub fn permute(_occid: OccId, occ: &mut Occultation, gplayers: &mut GPlayers, gpieces: &mut GPieces, @@ -297,10 +297,7 @@ pub fn permute(occid: OccId, if_let!{ Some(gpc) = gpieces.get(piece); else continue } if gpc.held.is_some() { continue } let occilk = (|| Some(ipieces.get(piece)?.occilk.as_ref()?))(); - if_let!{ Some(occilk) = occilk; else { - error!("{}", internal_error_bydebug(&(occid, &occ, &nr, piece))); - continue; - }} + if_let!{ Some(occilk) = occilk; else { continue; }} if_let!{ IOI::Mix(occilk) = occilk; else continue; } let (notches, pieces) = ilks.entry(*occilk.borrow()).or_default(); notches.push(notch); -- 2.30.2