rename gate to comparator

This commit is contained in:
Crispy 2024-12-14 17:30:37 +01:00
parent e98ad65ec3
commit 9792410f02
4 changed files with 49 additions and 48 deletions

View file

@ -125,7 +125,7 @@ impl Machine {
};
// `machine`` is being powered, in direction `dir``
match machine {
PTile::Gate(_) => (), // handled at the power propagation stage (end of step)
PTile::Comparator(_) => (), // handled at the power propagation stage (end of step)
PTile::Math(op) => {
if front_tile.is_blank() {
let pos_a = dir.left().step(pos);
@ -458,9 +458,9 @@ impl Machine {
}
}
}
Tile::Powerable(PTile::Gate(gate), state) => {
Tile::Powerable(PTile::Comparator(comp), state) => {
*state = true;
let gate = *gate;
let comp = *comp;
for dir in Direction::ALL {
let front_pos = dir.step(pos);
let source_pos = dir.opposite().step(pos);
@ -482,11 +482,11 @@ impl Machine {
let val_a = self.board.get_or_blank(pos_a).read_value();
let val_b = self.board.get_or_blank(pos_b).read_value();
let result = match gate {
GateType::LessThan => val_a < val_b,
GateType::GreaterThan => val_a > val_b,
GateType::Equal => val_a == val_b,
GateType::NotEqual => val_a != val_b,
let result = match comp {
Comparison::LessThan => val_a < val_b,
Comparison::GreaterThan => val_a > val_b,
Comparison::Equal => val_a == val_b,
Comparison::NotEqual => val_a != val_b,
};
if result {
self.powered.push(front_pos);