Add another random optimization
This commit is contained in:
parent
27734995dd
commit
47c3052fbe
20
src/main.rs
20
src/main.rs
@ -228,6 +228,26 @@ fn optimize(iters: usize, best_all: &mut f32, best_width: &mut f32, tris: &[Tria
|
||||
angles = start_angles.clone();
|
||||
flips = start_flips.clone();
|
||||
}
|
||||
angles = best_angles.clone();
|
||||
for idx in 0..tris.len() {
|
||||
for _ in 0..999 {
|
||||
let angle = rng.gen_range(-0.1, 0.1);
|
||||
angles[idx] += angle;
|
||||
let new = construct_world(tris, &angles, &best_flips);
|
||||
if new.width < *best_width {
|
||||
*best_all = new.width;
|
||||
//eprint!("\r[{}O{}o{}] at {:.3}", save_counter, iteration, i, new.width);
|
||||
//display::save_world(&format!("{}{}_{}_{}.svg", save_prefix, save_counter, iteration, i), &new);
|
||||
//iters = 99999;
|
||||
best = new;
|
||||
*best_width = best.width;
|
||||
found_better = true;
|
||||
*best_angles = angles.clone();
|
||||
} else {
|
||||
angles[idx] -= angle;
|
||||
}
|
||||
}
|
||||
}
|
||||
iteration += 1;
|
||||
}
|
||||
best
|
||||
|
Loading…
Reference in New Issue
Block a user