Modify bench and performance improvements.

This commit is contained in:
hal8174 2024-01-05 01:10:43 +01:00
parent b5dcbccf02
commit 96a86779f4
2 changed files with 25 additions and 45 deletions

View file

@ -27,16 +27,16 @@ pub enum PathField {
}
impl PathField {
// fn pos(&self) -> &Position {
// match self {
// PathField::Belt { pos, dir: _ } => pos,
// PathField::Underground {
// pos,
// dir: _,
// len: _,
// } => pos,
// }
// }
fn pos(&self) -> &Position {
match self {
PathField::Belt { pos, dir: _ } => pos,
PathField::Underground {
pos,
dir: _,
len: _,
} => pos,
}
}
fn dir(&self) -> &Direction {
match self {
@ -430,12 +430,22 @@ impl Bruteforce {
if second_last.dir().counter_clockwise() == dir
&& self.modify_underground(&pos, second_last.dir(), 2)
{
return true;
let (p, d) = self.path_field_end(self.modify_path().last().unwrap());
if self.is_next_free(&p, &d) {
return true;
} else {
return self.modify_remove();
}
}
}
PathField::Underground { pos, dir, len } => {
if self.modify_underground(&pos, &dir, len + 1) {
return true;
let (p, d) = self.path_field_end(self.modify_path().last().unwrap());
if self.is_next_free(&p, &d) {
return true;
} else {
return self.modify_remove();
}
}
}
}