Started working on optimizer
This commit is contained in:
@@ -13,7 +13,7 @@ pub(crate) struct IconBitfield {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl IconBitfield {
|
impl IconBitfield {
|
||||||
pub(crate) fn get_icon_bits(&self, icon: Icon) -> u8 {
|
pub fn get_icon_bits(&self, icon: Icon) -> u8 {
|
||||||
match icon {
|
match icon {
|
||||||
Icon::Circle => self.circle,
|
Icon::Circle => self.circle,
|
||||||
Icon::Square => self.square,
|
Icon::Square => self.square,
|
||||||
@@ -21,11 +21,11 @@ impl IconBitfield {
|
|||||||
Icon::Color => self.color,
|
Icon::Color => self.color,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub(crate) fn get_point_bits(&self) -> u8 {
|
pub fn get_point_bits(&self) -> u8 {
|
||||||
self.points
|
self.points
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn add_icon(&mut self, icon: Icon, index: u8) {
|
fn add_icon(&mut self, icon: Icon, index: u8) {
|
||||||
let field = match icon {
|
let field = match icon {
|
||||||
Icon::Circle => &mut self.circle,
|
Icon::Circle => &mut self.circle,
|
||||||
Icon::Square => &mut self.square,
|
Icon::Square => &mut self.square,
|
||||||
@@ -46,11 +46,12 @@ impl IconBitfield {
|
|||||||
CardField::Empty => (),
|
CardField::Empty => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(card: &Card) -> Self {
|
pub fn new(card: &Card) -> Self {
|
||||||
let mut result = Self::default();
|
let mut result = Self::default();
|
||||||
(0u8..)
|
(0u8..)
|
||||||
.zip(card.field.iter())
|
.zip(card.field.iter())
|
||||||
.for_each(|(index, field)| result.add_field(field.clone(), index));
|
.for_each(|(index, field)| result.add_field(*field, index));
|
||||||
result
|
result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ use crate::objective::Objective;
|
|||||||
mod card;
|
mod card;
|
||||||
mod icon_bitfield;
|
mod icon_bitfield;
|
||||||
mod objective;
|
mod objective;
|
||||||
|
mod optimizer;
|
||||||
|
|
||||||
use card::Card;
|
use card::Card;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
|||||||
5
canvas/src/optimizer.rs
Normal file
5
canvas/src/optimizer.rs
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
use crate::{CriteriaCard, icon_bitfield::IconBitfield, objective::Objective};
|
||||||
|
|
||||||
|
fn draw_painting(cards: &[IconBitfield], obj: Vec<(&CriteriaCard, u8)>) -> [usize; 3] {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user