chiark / gitweb /
hidden: Note everything as occulted, even the unoccultable
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 12 Jun 2022 22:00:23 +0000 (23:00 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 12 Jun 2022 22:00:23 +0000 (23:00 +0100)
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 <ijackson@chiark.greenend.org.uk>
src/hidden.rs
src/vpid.rs

index f1389081f55df8724f0ae3dc8932d79b1f5398d6..7f292a33e05526c37f3460c93458752b0708a073 100644 (file)
@@ -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) );
index 10ca8e326fa7459d01d0d733a8912abf4c46f582..2e3dd1a1ba25b334da53178733a50b5bf0a25bbf 100644 (file)
@@ -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);