Remove unnecessary prints
This commit is contained in:
parent
9fda072a13
commit
2d1b76cd6e
1 changed files with 14 additions and 40 deletions
44
src/main.rs
44
src/main.rs
|
@ -209,8 +209,8 @@ fn main() {
|
||||||
let new_price = layout.price();
|
let new_price = layout.price();
|
||||||
let price_diff = new_price as i64 - old_price as i64;
|
let price_diff = new_price as i64 - old_price as i64;
|
||||||
//eprintln!(" candidate is valid, price diff: {}.", price_diff);
|
//eprintln!(" candidate is valid, price diff: {}.", price_diff);
|
||||||
eprintln!("Removed a house (useless), diff {}", price_diff);
|
//eprintln!("Removed a house (useless), diff {}", price_diff);
|
||||||
eprintln!("Improved price: {}", new_price);
|
//eprintln!("Improved price: {}", new_price);
|
||||||
untried_houses = layout.houses().clone();
|
untried_houses = layout.houses().clone();
|
||||||
untried_houses.shuffle(&mut rng);
|
untried_houses.shuffle(&mut rng);
|
||||||
continue;
|
continue;
|
||||||
|
@ -228,51 +228,24 @@ fn main() {
|
||||||
|
|
||||||
new_candidates.sort_by(|a, b| city.get_price(&a).cmp(&city.get_price(&b)));
|
new_candidates.sort_by(|a, b| city.get_price(&a).cmp(&city.get_price(&b)));
|
||||||
if new_candidates.len() == 0 {
|
if new_candidates.len() == 0 {
|
||||||
eprintln!("Did not find candidate");
|
//eprintln!("Did not find candidate");
|
||||||
} else {
|
} else {
|
||||||
for (i, &candidate) in new_candidates.iter().enumerate() {
|
for (i, &candidate) in new_candidates.iter().enumerate() {
|
||||||
|
//eprint!("Found candidate {}...", i);
|
||||||
eprint!("Found candidate {}...", i);
|
|
||||||
|
|
||||||
let old_price = layout.price();
|
let old_price = layout.price();
|
||||||
layout.remove_house(house_index);
|
layout.remove_house(house_index);
|
||||||
|
layout.add_house(candidate);
|
||||||
|
|
||||||
if layout.is_valid() {
|
assert!(layout.is_valid());
|
||||||
// The candidate is not needed, the house was unnecessary
|
|
||||||
let new_price = layout.price();
|
let new_price = layout.price();
|
||||||
let price_diff = new_price as i64 - old_price as i64;
|
let price_diff = new_price as i64 - old_price as i64;
|
||||||
eprintln!("Removed a house, diff {}", price_diff);
|
//eprintln!(" candidate is valid, price diff: {}.", price_diff);
|
||||||
eprintln!("Move rectangle: {}", move_rectangle);
|
//eprintln!("Improved price: {}", new_price);
|
||||||
let house_rect = house.range_rectangle();
|
|
||||||
eprintln!("Printing map in rect around house: {}", house_rect);
|
|
||||||
for y in house_rect.top..=house_rect.bottom {
|
|
||||||
for x in house_rect.left..=house_rect.right {
|
|
||||||
eprint!("{}", layout.cover_count_xy(x, y));
|
|
||||||
}
|
|
||||||
eprintln!();
|
|
||||||
}
|
|
||||||
eprintln!("Improved price: {}", new_price);
|
|
||||||
untried_houses = layout.houses().clone();
|
untried_houses = layout.houses().clone();
|
||||||
untried_houses.shuffle(&mut rng);
|
untried_houses.shuffle(&mut rng);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
let candidate_index = layout.add_house(candidate);
|
|
||||||
|
|
||||||
if layout.is_valid() {
|
|
||||||
let new_price = layout.price();
|
|
||||||
let price_diff = new_price as i64 - old_price as i64;
|
|
||||||
eprintln!(" candidate is valid, price diff: {}.", price_diff);
|
|
||||||
eprintln!("Improved price: {}", new_price);
|
|
||||||
untried_houses = layout.houses().clone();
|
|
||||||
untried_houses.shuffle(&mut rng);
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
eprintln!(" candidate is invalid.");
|
|
||||||
layout.remove_house(candidate_index);
|
|
||||||
house_index = layout.add_house(house);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -280,6 +253,7 @@ fn main() {
|
||||||
if best_price.is_none() || price < best_price.unwrap() {
|
if best_price.is_none() || price < best_price.unwrap() {
|
||||||
best_price = Some(price);
|
best_price = Some(price);
|
||||||
eprintln!("Finished randomization, price: {}, new best, printing", price);
|
eprintln!("Finished randomization, price: {}, new best, printing", price);
|
||||||
|
println!("New best!");
|
||||||
println!("Price {}, seed {}", price, seed);
|
println!("Price {}, seed {}", price, seed);
|
||||||
print_houses(&layout.houses());
|
print_houses(&layout.houses());
|
||||||
println!();
|
println!();
|
||||||
|
|
Loading…
Reference in a new issue