Improve tracing output

This commit is contained in:
hal8174 2025-02-17 23:08:06 +01:00
parent cebdee4ec7
commit 81edc8e67a
6 changed files with 53 additions and 24 deletions

View file

@ -40,22 +40,42 @@ fn place_block(
let dir = rng.random::<Direction>();
let pos = match dir {
Direction::Up => Position::new(
rng.random_range(0..=(size.x - b.size.x)),
rng.random_range(0..=(size.y - b.size.y)),
),
Direction::Right => Position::new(
rng.random_range((b.size.y - 1)..size.x),
rng.random_range(0..=(size.y - b.size.x)),
),
Direction::Down => Position::new(
rng.random_range((b.size.x - 1)..size.x),
rng.random_range((b.size.y - 1)..size.y),
),
Direction::Left => Position::new(
rng.random_range(0..=(size.x - b.size.y)),
rng.random_range((b.size.x - 1)..size.y),
),
Direction::Up => {
if size.x - b.size.x < 0 || size.y - b.size.y < 0 {
continue;
}
Position::new(
rng.random_range(0..=(size.x - b.size.x)),
rng.random_range(0..=(size.y - b.size.y)),
)
}
Direction::Right => {
if size.y - b.size.x < 0 || size.x - b.size.y < 0 {
continue;
}
Position::new(
rng.random_range((b.size.y - 1)..size.x),
rng.random_range(0..=(size.y - b.size.x)),
)
}
Direction::Down => {
if size.x - b.size.x < 0 || size.y - b.size.y < 0 {
continue;
}
Position::new(
rng.random_range((b.size.x - 1)..size.x),
rng.random_range((b.size.y - 1)..size.y),
)
}
Direction::Left => {
if size.y - b.size.x < 0 || size.x - b.size.y < 0 {
continue;
}
Position::new(
rng.random_range(0..=(size.x - b.size.y)),
rng.random_range((b.size.x - 1)..size.y),
)
}
};
let current = Block::new(pos, dir, b.size);