canonicalize colors

This commit is contained in:
Jana Dönszelmann 2026-01-02 16:24:24 +01:00
parent 37b01f2102
commit 6fc85b3d82
No known key found for this signature in database

View file

@ -78,6 +78,12 @@ impl<const TOWER_HEIGHT: usize> Tower<TOWER_HEIGHT> {
tower tower
} }
fn map(self, f: impl FnMut(Option<Ring>) -> Option<Ring>) -> Self {
Self {
rings: self.rings.map(f),
}
}
fn burried_score(&self) -> usize { fn burried_score(&self) -> usize {
let mut ring_type = None; let mut ring_type = None;
let mut same_ring_type_score = 0; let mut same_ring_type_score = 0;
@ -357,7 +363,21 @@ impl<const TOWER_HEIGHT: usize> Game<TOWER_HEIGHT> {
(rings, *index) (rings, *index)
}); });
for x in filtered_towers.into_iter().map(|(_, x)| x).enumerate() { let mut color_assignment = [None::<Ring>; 100];
let mut num_seen = 0;
let relabelled_towers = filtered_towers.iter().map(|(_, x)| x).map(|tower| {
tower.map(|ring| {
ring.map(|ring| {
*color_assignment[ring.0.get()].get_or_insert_with(|| {
num_seen += 1;
let ring = Ring(NonZero::new(num_seen).unwrap());
ring
})
})
})
});
for x in relabelled_towers.into_iter().enumerate() {
x.hash(&mut hasher); x.hash(&mut hasher);
} }