config.rs

2.0 kB · rust · 72 lines

1/// The odd multiplier ladder grids and canvases climb.2pub const LADDER: [usize; 6] = [1, 3, 5, 7, 9, 11];34/// The frames tempo in frames per second.5pub const FPS: usize = 8;67/// The heatmap tempo in frames per second.8pub const HEATMAP_FPS: usize = 32;910/// The freeze at the start and end of the timeline, in microseconds.11pub const FREEZE_US: u64 = 500_000;1213/// The freeze on the held last frame between segments, in microseconds.14pub const INTER_FREEZE_US: u64 = 500_000;1516/// The square side an assembler scales frames to, in pixels.17pub const SIZE: usize = 1080;1819/// The editorial caps one quest is generated under.20#[derive(Clone, Debug)]21pub struct Config {22    /// The generation cap of one chapter.23    pub max_generations: usize,24    /// The chapter cap of one attempt.25    pub max_segments: usize,26    /// The canvas side cap in cells.27    pub max_canvas: usize,28    /// The smallest tile side drawn.29    pub min_tile: usize,30    /// The largest tile side drawn.31    pub max_tile: usize,32    /// The smallest mask side drawn.33    pub min_mask: usize,34    /// The largest mask side drawn.35    pub max_mask: usize,36    /// The attempt cap before the quest gives up.37    pub attempts: usize,38}3940impl Default for Config {41    fn default() -> Config {42        Config {43            max_generations: 64,44            max_segments: 8,45            max_canvas: 256,46            min_tile: 3,47            max_tile: 128,48            min_mask: 3,49            max_mask: 64,50            attempts: 64,51        }52    }53}5455#[cfg(test)]56mod tests {57    use super::*;58    #[test]59    fn the_ladder_is_odd_and_ascending() {60        assert!(LADDER.iter().all(|i| i % 2 == 1));61        assert!(LADDER.windows(2).all(|w| w[0] < w[1]));62    }63    #[test]64    fn the_defaults_carry_the_product_caps() {65        let config = Config::default();66        assert_eq!(config.max_generations, 64);67        assert_eq!(config.max_segments, 8);68        assert_eq!(config.max_canvas, 256);69        assert_eq!(config.max_tile, 128);70        assert_eq!(config.max_mask, 64);71    }72}