Browse Source

Remove unnecessary prints

master
Jirka Sejkora 3 years ago
parent
commit
2d1b76cd6e
  1. 54
      src/main.rs

54
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,50 +228,23 @@ 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!(" candidate is valid, price diff: {}.", price_diff);
eprintln!("Removed a house, diff {}", price_diff); //eprintln!("Improved price: {}", new_price);
eprintln!("Move rectangle: {}", move_rectangle); untried_houses = layout.houses().clone();
let house_rect = house.range_rectangle(); untried_houses.shuffle(&mut rng);
eprintln!("Printing map in rect around house: {}", house_rect); break;
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);
}
} }
} }
} }
@ -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…
Cancel
Save