Final hack
This commit is contained in:
parent
ffac5baa99
commit
9fe127cab7
33
src/main.rs
33
src/main.rs
@ -39,14 +39,14 @@ impl cmp::PartialOrd for World {
|
|||||||
|
|
||||||
fn random_world(rng: &mut SmallRng, tris: &mut Vec<Triangle>, angles: &mut [f32], flips: &mut Vec<bool>) -> World {
|
fn random_world(rng: &mut SmallRng, tris: &mut Vec<Triangle>, angles: &mut [f32], flips: &mut Vec<bool>) -> World {
|
||||||
//tris.shuffle(rng);
|
//tris.shuffle(rng);
|
||||||
*tris = vec![tris[0], tris[9], tris[12], tris[6], tris[1], tris[4], tris[15], tris[5], tris[13], tris[7], tris[12], tris[2], tris[22], tris[18], tris[20], tris[17], tris[19], tris[3], tris[21], tris[16], tris[14], tris[8], tris[10]];
|
*tris = vec![tris[9], tris[12], tris[6], tris[1], tris[4], tris[0], tris[15], tris[5], tris[13], tris[7], tris[12], tris[2], tris[22], tris[18], tris[20], tris[17], tris[19], tris[3], tris[21], tris[16], tris[14], tris[8], tris[10]];
|
||||||
*flips = vec![true, false, true, true, false, false, true, false, true, false, false, true, false, true, true, true, true, false, false, true, false, false, false];
|
*flips = vec![false, true, true, false, false, true, true, false, true, false, false, true, false, true, true, true, true, false, false, true, false, false, false];
|
||||||
angles[0] = 0.9 * PI;
|
angles[0] = 1.45 * PI;
|
||||||
angles[1] = 1.35 * PI;
|
angles[1] = 1.37 * PI;
|
||||||
angles[2] = 1.27 * PI;
|
angles[2] = 1.5 * PI;
|
||||||
angles[3] = 1.4 * PI;
|
angles[3] = 0.6 * PI;
|
||||||
angles[4] = 0.5 * PI;
|
angles[4] = 0.1 * PI;
|
||||||
angles[5] = 0.0;
|
angles[5] = 1.0 * PI;
|
||||||
angles[6] = 1.5 * PI;
|
angles[6] = 1.5 * PI;
|
||||||
angles[7] = 1.1 * PI;
|
angles[7] = 1.1 * PI;
|
||||||
angles[8] = PI;
|
angles[8] = PI;
|
||||||
@ -275,6 +275,23 @@ fn optimize(iters: usize, best_all: &mut f32, best_width: &mut f32, tris: &[Tria
|
|||||||
angles[idx] -= angle;
|
angles[idx] -= angle;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for i in 1000..2499 {
|
||||||
|
let angle = rng.gen_range(-PI, PI);
|
||||||
|
angles[idx] += angle;
|
||||||
|
let new = construct_world(tris, &angles, &best_flips);
|
||||||
|
if new.width < *best_width {
|
||||||
|
*best_all = new.width;
|
||||||
|
eprint!("\r[{}O{}I{}EE{}] at {:.3}", save_counter, iteration, idx, 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;
|
iteration += 1;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user