canonicalize colors
This commit is contained in:
parent
37b01f2102
commit
6fc85b3d82
1 changed files with 21 additions and 1 deletions
22
src/main.rs
22
src/main.rs
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue