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