Řešení KSP úlohy 33-3-4 Obsazování území https://ksp.mff.cuni.cz/h/ulohy/33/zadani3.html#task-33-3-4
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
553 B

use rand::Rng;
use crate::city::{SIZE, House, HouseLayout};
use rand::prelude::StdRng;
pub(crate) fn populate_random(layout: &mut HouseLayout, rng: &mut StdRng) {
loop {
loop {
let x = rng.gen_range(0..SIZE);
let y = rng.gen_range(0..SIZE);
let house = House::new(x, y);
if layout.city.is_house_xy(x, y) && !layout.is_covered(house) {
layout.add_house(house);
break;
}
}
if layout.is_valid() {
break;
}
}
}