Fix binary map visitor

This commit is contained in:
eraden 2024-10-03 07:11:40 +02:00
parent bb350d3ec7
commit 1b4dab55c6

View File

@ -578,6 +578,7 @@ impl<const X: usize, const Y: usize, const SIZE: usize> BinaryMapVisitor<X, Y, S
bw.push(MazePart::Wall); bw.push(MazePart::Wall);
bw.copy(&[MazePart::Wall; X]); bw.copy(&[MazePart::Wall; X]);
bw.copy(&[MazePart::Wall; X]);
let mut top_line = [MazePart::Noop; SIZE]; let mut top_line = [MazePart::Noop; SIZE];
let mut bottom_line = [MazePart::Noop; SIZE]; let mut bottom_line = [MazePart::Noop; SIZE];
@ -604,10 +605,8 @@ impl<const X: usize, const Y: usize, const SIZE: usize> BinaryMapVisitor<X, Y, S
} else { } else {
MazePart::Wall MazePart::Wall
}); });
tl.push(MazePart::Wall); bl.push(MazePart::Wall);
} }
assert!(top_line.iter().any(|b| *b != MazePart::Noop));
assert!(bottom_line.iter().any(|b| *b != MazePart::Noop));
bw.copy(&top_line); bw.copy(&top_line);
bw.copy(&bottom_line); bw.copy(&bottom_line);
@ -732,8 +731,8 @@ mod print_tests {
impl std::fmt::Debug for MB { impl std::fmt::Debug for MB {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "\n"); write!(f, "\n");
for x in 0..11 { for y in 0..11 {
for y in 0..11 { for x in 0..11 {
let c = match self.0[y * 11 + x] { let c = match self.0[y * 11 + x] {
P => '.', P => '.',
W => '#', W => '#',