This commit is contained in:
18
Cargo.lock
generated
18
Cargo.lock
generated
@@ -5,3 +5,21 @@ version = 4
|
||||
[[package]]
|
||||
name = "canvas"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"itertools",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "either"
|
||||
version = "1.15.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719"
|
||||
|
||||
[[package]]
|
||||
name = "itertools"
|
||||
version = "0.14.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2b192c782037fadd9cfa75548310488aabdbf3d2da73885b31bd0abd03351285"
|
||||
dependencies = [
|
||||
"either",
|
||||
]
|
||||
|
||||
@@ -4,3 +4,4 @@ version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
itertools = "0.14.0"
|
||||
|
||||
@@ -69,17 +69,17 @@ impl IntoIterator for IconSet {
|
||||
}
|
||||
|
||||
impl Objective {
|
||||
pub fn count_matches(&self, painting: &Painting) -> u8 {
|
||||
pub fn count_matches_bitfield(&self, bitfield: &IconBitfield) -> u8 {
|
||||
match self {
|
||||
Objective::AllFields => {
|
||||
if IconBitfield::from_painting(painting).all_fields() == 0b11111 {
|
||||
if bitfield.all_fields() == 0b11111 {
|
||||
1
|
||||
} else {
|
||||
0
|
||||
}
|
||||
}
|
||||
Objective::IconsUsed(icons) => {
|
||||
let bits = IconBitfield::from_painting(painting);
|
||||
let bits = bitfield;
|
||||
if icons.into_iter().all(|i| bits.get_icon_bits(i) > 0) {
|
||||
1
|
||||
} else {
|
||||
@@ -87,7 +87,7 @@ impl Objective {
|
||||
}
|
||||
}
|
||||
Objective::ExactlyNIcons((icons, count)) => {
|
||||
let bits = IconBitfield::from_painting(painting);
|
||||
let bits = bitfield;
|
||||
|
||||
if icons
|
||||
.into_iter()
|
||||
@@ -101,7 +101,7 @@ impl Objective {
|
||||
}
|
||||
}
|
||||
Objective::NInARow(icon, count) => {
|
||||
let mut bits = IconBitfield::from_painting(painting).get_icon_bits(*icon);
|
||||
let mut bits = bitfield.get_icon_bits(*icon);
|
||||
let bitmask = (1 << count) - 1;
|
||||
let mut res_count = 0;
|
||||
while bits > 0 {
|
||||
@@ -119,6 +119,10 @@ impl Objective {
|
||||
_ => todo!(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn count_matches(&self, painting: &Painting) -> u8 {
|
||||
self.count_matches_bitfield(&IconBitfield::from_painting(painting))
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -1,5 +1,14 @@
|
||||
// use crate::{CriteriaCard, icon_bitfield::IconBitfield};
|
||||
use itertools::Itertools;
|
||||
|
||||
// fn draw_painting(cards: &[IconBitfield], obj: Vec<(&CriteriaCard, u8)>) -> [usize; 3] {
|
||||
// todo!()
|
||||
// }
|
||||
use crate::{CriteriaCard, icon_bitfield::IconBitfield};
|
||||
|
||||
fn draw_painting(cards: &[IconBitfield], _obj: Vec<(&CriteriaCard, u8)>) -> [usize; 3] {
|
||||
for stack in cards.iter().permutations(3) {
|
||||
let stack: [&IconBitfield; 3] = stack.try_into().unwrap();
|
||||
let mut painting = stack[0].clone();
|
||||
painting.layer_below(stack[1]).layer_below(stack[2]);
|
||||
// obj.iter()
|
||||
// .map(|x| x.0.objective.count_matches_bitfield(&painting));
|
||||
}
|
||||
todo!()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user