diff --git a/src/lib.rs b/src/lib.rs index ab95b41..24cab83 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -186,9 +186,6 @@ impl fmt::Display for Universe { } } -/// Number of currently supported shapes -pub const SHAPES_N: u8 = 6; - #[derive(Debug)] pub enum ShapeError { OutOfRange, @@ -210,7 +207,7 @@ impl std::fmt::Display for ShapeError { /// `from_figur()` /// `IndexOutOfRange` pub fn get_shape(wh: u32, i: usize) -> Result { - if i > SHAPES_N as usize { + if i > shapes::N as usize { return Err(ShapeError::OutOfRange); } @@ -227,6 +224,8 @@ pub fn get_shape(wh: u32, i: usize) -> Result { 5 => Universe::from_figur(wh, &shapes::rabbits()), + 6 => Universe::from_figur(wh, &shapes::bonk_tie()), + _ => Err(ShapeError::OutOfRange), } // todo!(); diff --git a/src/main.rs b/src/main.rs index 206feac..c52dc61 100644 --- a/src/main.rs +++ b/src/main.rs @@ -110,7 +110,7 @@ fn print_events() -> io::Result<()> { } else if kmaps::restart().contains(&event) { universe = get_shape(wh, i).unwrap(); } else if kmaps::next().contains(&event) { - if i + 1 != SHAPES_N as usize { + if i + 1 != shapes::N as usize { i += 1; } else { i = 0; diff --git a/src/shapes.rs b/src/shapes.rs index 45cbbcf..a41727c 100644 --- a/src/shapes.rs +++ b/src/shapes.rs @@ -1,19 +1,7 @@ use super::*; -pub fn two_engine_cordership() -> String { - todo!(); - // [ - // "_".repeat(19), - // "##".into(), - // "_".repeat(19), - // "\n".into(), - // "_".repeat(19), - // "####".into(), - // "_".repeat(17), - // "\n".into(), - // ] - // .concat() -} +/// Number of currently supported shapes +pub const N: u8 = 7; pub fn copperhead() -> Vec { // ["_".repeat(5), "#_##".into(), "_".repeat(7), "#".into(), "_".repeat(6), "#".into(), "___##___#__###_"] @@ -76,14 +64,6 @@ pub fn gosper_glider_gun() -> Vec { .to_vec() } -pub fn sir_robin() -> String { - todo!() -} - -pub fn snark_loop() -> String { - todo!() -} - pub fn featherweigth_spaceship() -> Vec { ["__#".into(), "#_#".into(), "_##".into()].to_vec() } @@ -98,6 +78,18 @@ pub fn rabbits() -> Vec { .to_vec() } +/// 3×5 +pub fn bonk_tie() -> Vec { + [ + "##_".into(), + "##_".into(), + "__#".into(), + "__#".into(), + "__#".into(), + ] + .to_vec() +} + pub fn rand(width: u32, height: u32) -> Universe { let cells = (0..width * height) .map(|_i| { @@ -135,3 +127,26 @@ pub fn stripes(width: u32, height: u32) -> Universe { cells, } } + +pub fn two_engine_cordership() -> String { + todo!(); + // [ + // "_".repeat(19), + // "##".into(), + // "_".repeat(19), + // "\n".into(), + // "_".repeat(19), + // "####".into(), + // "_".repeat(17), + // "\n".into(), + // ] + // .concat() +} + +pub fn sir_robin() -> String { + todo!() +} + +pub fn snark_loop() -> String { + todo!() +}