use super::angles::upscale_angles;
use super::snake::Snake;
use crate::cyclotomic::{HasZZ4, HasZZ6, HasZZ10, HasZZ12};
pub fn square<T: HasZZ4>() -> Snake<T> {
Snake::try_from(upscale_angles::<T>(4, &[1, 1, 1, 1]).as_slice()).unwrap()
}
pub fn triangle<T: HasZZ6>() -> Snake<T> {
Snake::try_from(upscale_angles::<T>(6, &[2, 2, 2]).as_slice()).unwrap()
}
pub fn hexagon<T: HasZZ6>() -> Snake<T> {
Snake::try_from(upscale_angles::<T>(6, &[1, 1, 1, 1, 1, 1]).as_slice()).unwrap()
}
pub fn spectre<T: HasZZ12>() -> Snake<T> {
Snake::try_from(
upscale_angles::<T>(12, &[3, 2, 0, 2, -3, 2, 3, 2, -3, 2, 3, -2, 3, -2]).as_slice(),
)
.unwrap()
}
pub fn penrose_p3_narrow<T: HasZZ10>() -> Snake<T> {
let seq: &[i8] = &[
1, 0, -1, 2, -1, 0, 0, 4, 0, 0, -1, 2, -1, 0, 1, 0, 1, -2, 1, 0, 0, 4, 0, 0, 1, -2, 1, 0, ];
Snake::try_from(upscale_angles::<T>(10, seq).as_slice()).unwrap()
}
pub fn penrose_p3_wide<T: HasZZ10>() -> Snake<T> {
let seq: &[i8] = &[
2, 0, -1, 2, -1, 0, 0, 3, 0, 0, 1, -2, 1, 0, 2, 0, 0, -1, 2, -1, 0, 3, 0, 1, -2, 1, 0, 0, ];
Snake::try_from(upscale_angles::<T>(10, seq).as_slice()).unwrap()
}
#[allow(non_snake_case)]
pub fn tetromino_O<T: HasZZ4>() -> Snake<T> {
Snake::try_from(upscale_angles::<T>(4, &[0, 1, 0, 1, 0, 1, 0, 1]).as_slice()).unwrap()
}
#[allow(non_snake_case)]
pub fn tetromino_I<T: HasZZ4>() -> Snake<T> {
Snake::try_from(upscale_angles::<T>(4, &[0, 0, 0, 1, 1, 0, 0, 0, 1, 1]).as_slice()).unwrap()
}
#[allow(non_snake_case)]
pub fn tetromino_T<T: HasZZ4>() -> Snake<T> {
Snake::try_from(upscale_angles::<T>(4, &[-1, 1, 1, -1, 1, 1, 0, 0, 1, 1]).as_slice()).unwrap()
}
#[allow(non_snake_case)]
pub fn tetromino_S<T: HasZZ4>() -> Snake<T> {
Snake::try_from(upscale_angles::<T>(4, &[-1, 1, 1, 0, 1, -1, 1, 1, 0, 1]).as_slice()).unwrap()
}
#[allow(non_snake_case)]
pub fn tetromino_Z<T: HasZZ4>() -> Snake<T> {
Snake::try_from(upscale_angles::<T>(4, &[-1, 1, 0, 1, 1, -1, 1, 0, 1, 1]).as_slice()).unwrap()
}
#[allow(non_snake_case)]
pub fn tetromino_J<T: HasZZ4>() -> Snake<T> {
Snake::try_from(upscale_angles::<T>(4, &[-1, 1, 1, 0, 1, 0, 0, 1, 1, 0]).as_slice()).unwrap()
}
#[allow(non_snake_case)]
pub fn tetromino_L<T: HasZZ4>() -> Snake<T> {
Snake::try_from(upscale_angles::<T>(4, &[-1, 0, 1, 1, 0, 0, 1, 0, 1, 1]).as_slice()).unwrap()
}
#[cfg(test)]
mod tests {
use super::*;
use crate::cyclotomic::{ZZ10, ZZ24};
use crate::geom::rat::Rat;
#[test]
fn test_upscaling() {
let seq_zz24: Vec<i8> = vec![6, 4, 0, 4, -6, 4, 6, 4, -6, 4, 6, -4, 6, -4];
let s: Snake<ZZ24> = spectre();
assert_eq!(s.angles(), seq_zz24);
}
#[test]
fn test_penrose() {
let fat_rat: Rat<ZZ10> = Rat::try_from(&penrose_p3_wide()).unwrap();
let thin_rat: Rat<ZZ10> = Rat::try_from(&penrose_p3_narrow()).unwrap();
let mut penta_star = fat_rat.glue((18, 24), &fat_rat);
penta_star = penta_star.glue((3, 39), &penta_star);
penta_star = penta_star.glue((32, 24), &fat_rat);
let mut penta_circ = penta_star.clone();
penta_circ = penta_circ.glue((3, 25), &thin_rat);
penta_circ = penta_circ.glue((10, 25), &thin_rat);
penta_circ = penta_circ.glue((10, 25), &thin_rat);
penta_circ = penta_circ.glue((10, 25), &thin_rat);
penta_circ = penta_circ.glue((10, 25), &thin_rat);
assert_eq!(penta_circ.len(), 70);
}
}