Pick rule matches based on exact position, but use an origin offset for rotated rules to fix directional bias for rotated rules.

This also avoids the bias toward larger rules caused by checking for overlapping matches at the chosen position.
This commit is contained in:
Crispy 2024-05-30 20:52:39 +02:00
parent f556c80f29
commit 4793bc1b8f
3 changed files with 112 additions and 112 deletions

View file

@ -79,12 +79,8 @@ impl eframe::App for UScope {
ctx.request_repaint();
let sim_frame = Instant::now();
for _ in 0..self.speed {
// benchmarks made with sand_stress_test at 50000 speed in a release build
// ~50ms
self.dish.try_one_position_overlapped();
// ~35ms
// TODO: has directional bias, figure out why and fix it
// self.dish.fire_blindly_cached();
self.dish.try_one_location();
// self.dish.apply_one_match();
}
let sim_time = sim_frame.elapsed();
// self.sim_times.push(sim_time.as_micros());
@ -107,6 +103,9 @@ impl eframe::App for UScope {
if ui.button("regenerate rules and cache").clicked() {
self.dish.update_all_rules();
}
if ui.button("debug cache").clicked() {
self.dish.dbg_cache();
}
ui.horizontal(|ui| {
if ui.button("Save").clicked() {
self.save_universe();
@ -223,8 +222,11 @@ impl eframe::App for UScope {
self.brush = clicked_cell;
}
} else {
self.dish.set_cell(x, y, self.brush);
self.dish.update_cache(x as isize, y as isize, 1, 1);
let old = self.dish.get_cell(x, y);
if Some(self.brush) != old {
self.dish.set_cell(x, y, self.brush);
self.dish.update_cache(x as isize, y as isize, 1, 1);
}
}
}
});
@ -298,6 +300,9 @@ fn rule_editor(
ui.label("fail rate:");
ui.add(DragValue::new(&mut rule.failrate));
ui.label(format!("variants: {}", rule.variant_count()));
if ui.button("debug").clicked() {
rule.dbg_variants();
}
});
let cells_y = rule.height();
let cells_x = rule.width();