Finish hack
This commit is contained in:
parent
1fdc5f4b7a
commit
ffac5baa99
@ -8,6 +8,8 @@ edition = "2018"
|
|||||||
codegen-units = 1
|
codegen-units = 1
|
||||||
opt-level = 3
|
opt-level = 3
|
||||||
panic = "abort"
|
panic = "abort"
|
||||||
|
lto = "fat"
|
||||||
|
incremental = false
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
geo = { git = "https://github.com/FliegendeWurst/geo" }
|
geo = { git = "https://github.com/FliegendeWurst/geo" }
|
||||||
|
37
src/main.rs
37
src/main.rs
@ -39,41 +39,41 @@ 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[5], tris[13], tris[7], tris[15], 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[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]];
|
||||||
*flips = vec![true, false, true, true, false, false, false, true, false, true, false, true, false, true, true, false, true, false, false, true, false, false, false];
|
*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];
|
||||||
angles[0] = 0.9 * PI;
|
angles[0] = 0.9 * PI;
|
||||||
angles[1] = 1.4 * PI;
|
angles[1] = 1.35 * PI;
|
||||||
angles[2] = 1.3 * PI;
|
angles[2] = 1.27 * PI;
|
||||||
angles[3] = 1.4 * PI;
|
angles[3] = 1.4 * PI;
|
||||||
angles[4] = 0.5 * PI;
|
angles[4] = 0.5 * PI;
|
||||||
angles[5] = PI;
|
angles[5] = 0.0;
|
||||||
angles[6] = 0.0;
|
angles[6] = 1.5 * PI;
|
||||||
angles[7] = PI;
|
angles[7] = 1.1 * PI;
|
||||||
angles[8] = 0.8 * PI;
|
angles[8] = PI;
|
||||||
angles[9] = 0.1 * PI;
|
angles[9] = 0.8 * PI;
|
||||||
angles[10] = 0.05 * PI;
|
angles[10] = 0.05 * PI;
|
||||||
angles[11] = 0.0;
|
angles[11] = 0.0;
|
||||||
angles[12] = 1.7 * PI;
|
angles[12] = 1.7 * PI;
|
||||||
angles[13] = 0.5 * PI;
|
angles[13] = 0.5 * PI;
|
||||||
angles[14] = 0.0;
|
angles[14] = 0.0;
|
||||||
angles[15] = PI;
|
angles[15] = 2.0 * PI;
|
||||||
angles[16] = 1.5 * PI;
|
angles[16] = 1.5 * PI;
|
||||||
angles[17] = 1.1 * PI;
|
angles[17] = 1.1 * PI;
|
||||||
angles[18] = PI;
|
angles[18] = 0.6 * PI;
|
||||||
angles[19] = PI;
|
angles[19] = 0.7 * PI;
|
||||||
angles[20] = 0.0;
|
angles[20] = -0.4 * PI;
|
||||||
angles[21] = 2.0 * PI;
|
angles[21] = 0.5 * PI;
|
||||||
angles[22] = PI;
|
angles[22] = 0.6 * PI;
|
||||||
let mut world = World { tris: Vec::with_capacity(tris.len()), width: 0.0 };
|
let mut world = World { tris: Vec::with_capacity(tris.len()), width: 0.0 };
|
||||||
for (idx, tri) in tris.iter().enumerate() {
|
for (idx, tri) in tris.iter().enumerate() {
|
||||||
let mut tri = *tri;
|
let mut tri = *tri;
|
||||||
flips[idx] = rng.gen();
|
//flips[idx] = rng.gen();
|
||||||
if flips[idx] {
|
if flips[idx] {
|
||||||
tri.0.x *= -1.0;
|
tri.0.x *= -1.0;
|
||||||
tri.1.x *= -1.0;
|
tri.1.x *= -1.0;
|
||||||
tri.2.x *= -1.0;
|
tri.2.x *= -1.0;
|
||||||
}
|
}
|
||||||
angles[idx] = rng.gen_range(0.0, 2.0*PI);
|
//angles[idx] = rng.gen_range(0.0, 2.0*PI);
|
||||||
tri = rotate(tri, angles[idx]);
|
tri = rotate(tri, angles[idx]);
|
||||||
let minx = min(min(tri.0.x, tri.1.x), tri.2.x);
|
let minx = min(min(tri.0.x, tri.1.x), tri.2.x);
|
||||||
tri.0.x -= minx;
|
tri.0.x -= minx;
|
||||||
@ -207,7 +207,8 @@ fn one_main(tris: &mut Vec<Triangle>) -> World {
|
|||||||
let mut best_width = f32::MAX;
|
let mut best_width = f32::MAX;
|
||||||
let mut best_all = f32::MAX;
|
let mut best_all = f32::MAX;
|
||||||
let _random = random_world(&mut rng, tris, &mut angles, &mut flips);
|
let _random = random_world(&mut rng, tris, &mut angles, &mut flips);
|
||||||
optimize(69999, &mut best_all, &mut best_width, &tris, &mut angles, &mut flips, &mut rng, "rand_", 0)
|
//display::save_world("/tmp/rand.svg", &_random);
|
||||||
|
optimize(0, &mut best_all, &mut best_width, &tris, &mut angles, &mut flips, &mut rng, "rand_", 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
|
Loading…
Reference in New Issue
Block a user