maps.rs

cdk-rsx/crates/crypto/private-los/src/maps.rs

1//! Reproducible public geometry. All maps are prefixes of the same distributed2//! 8-by-8 set of unit segments; none lies on an outer supporting boundary.34use crate::program::Wall;56/// Segment `t` uses bit-reversed Morton coordinates, so the small prefixes7/// spread through the board before filling in the intervening positions.8const fn walls<const N: usize>() -> [Wall; N] {9    let mut result = [Wall {10        x1: 0,11        y1: 0,12        x2: 0,13        y2: 0,14    }; N];15    let mut t = 0;16    while t < N {17        let i = ((t & 1) << 2) | ((t & 4) >> 1) | ((t & 16) >> 4);18        let j = ((t & 2) << 1) | ((t & 8) >> 2) | ((t & 32) >> 5);19        let x = (2 * i + 1) as u8;20        let y = (2 * j + 1) as u8;21        let parity = (i ^ (i >> 1) ^ (i >> 2) ^ j ^ (j >> 1) ^ (j >> 2)) & 1;22        result[t] = if parity == 0 {23            Wall {24                x1: x,25                y1: y,26                x2: x + 1,27                y2: y,28            }29        } else {30            Wall {31                x1: x,32                y1: y,33                x2: x,34                y2: y + 1,35            }36        };37        t += 1;38    }39    result40}4142pub const WALLS_0: [Wall; 0] = walls();43pub const WALLS_4: [Wall; 4] = walls();44pub const WALLS_16: [Wall; 16] = walls();45pub const WALLS_64: [Wall; 64] = walls();