<commit_before>use std::result;
use super::BLOCK_SIZE;

pub type Result<T> = result::Result<T, String>;

const movement_speed: f64 = 1.0;

pub static TETROMINOES: [Tetromino; 7] = [
    Tetromino {
        name: Shape::I,
        blocks: [[0, 1, 0, 0], [0, 1, 0, 0], [0, 1, 0, 0], [0, 1, 0, 0]],
        x_offset: 0.0,
        y_offset: 0.0
    },
    Tetromino {
        name: Shape::J,
        blocks: [[0, 1, 0, 0], [0, 1, 0, 0], [1, 1, 0, 0], [0, 0, 0, 0]],
        x_offset: 0.0,
        y_offset: 0.0
    },
    Tetromino {
        name: Shape::L,
        blocks: [[0, 1, 0, 0], [0, 1, 0, 0], [0, 1, 1, 0], [0, 0, 0, 0]],
        x_offset: 0.0,
        y_offset: 0.0
    },
    Tetromino {
        name: Shape::O,
        blocks: [[1, 1, 0, 0], [1, 1, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]],
        x_offset: 0.0,
        y_offset: 0.0
    },
    Tetromino {
        name: Shape::S,
        blocks: [[0, 0, 0, 0], [0, 1, 1, 0], [1, 1, 0, 0], [0, 0, 0, 0]],
        x_offset: 0.0,
        y_offset: 0.0
    },
    Tetromino {
        name: Shape::T,
        blocks: [[0, 0, 0, 0], [1, 1, 1, 0], [0, 1, 0, 0], [0, 0, 0, 0]],
        x_offset: 0.0,
        y_offset: 0.0
    },
    Tetromino {
        name: Shape::Z,
        blocks: [[0, 0, 0, 0], [1, 1, 0, 0], [0, 1, 1, 0], [0, 0, 0, 0]],
        x_offset: 0.0,
        y_offset: 0.0
    },  
];

#[derive(PartialEq, Debug, Clone, Copy)]
pub enum Shape {
    I,
    O,
    T,
    S,
    Z,
    J,
    L
}

#[derive(Debug, Clone, Copy)]
pub struct Tetromino {
    pub name: Shape,
    pub blocks: [[u8; 4]; 4],
    pub x_offset: f64, // offset (in block cell units) of the top left cell
    pub y_offset: f64
}

impl Tetromino {
    pub fn rotate_right(&mut self) {
        if self.name == Shape::O {
            return
        }
        let mut new_blocks = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]];
        for (r, row) in self.blocks.iter().enumerate() {<commit_msg>set spawn location for blocks to middle of board<commit_after>use std::result;
use super::BLOCK_SIZE;
use super::BOARD_WIDTH;
use super::BOARD_HEIGHT;

pub type Result<T> = result::Result<T, String>;

const movement_speed: f64 = 1.0;

pub static TETROMINOES: [Tetromino; 7] = [
    Tetromino {
        name: Shape::I,
        blocks: [[0, 1, 0, 0], [0, 1, 0, 0], [0, 1, 0, 0], [0, 1, 0, 0]],
        x_offset: (BOARD_WIDTH as f64 / 2.0) - 2.0,
        y_offset: 0.0
    },
    Tetromino {
        name: Shape::J,
        blocks: [[0, 1, 0, 0], [0, 1, 0, 0], [1, 1, 0, 0], [0, 0, 0, 0]],
        x_offset: (BOARD_WIDTH as f64 / 2.0) - 2.0,
        y_offset: 0.0
    },
    Tetromino {
        name: Shape::L,
        blocks: [[0, 1, 0, 0], [0, 1, 0, 0], [0, 1, 1, 0], [0, 0, 0, 0]],
        x_offset: (BOARD_WIDTH as f64 / 2.0) - 2.0,
        y_offset: 0.0
    },
    Tetromino {
        name: Shape::O,
        blocks: [[1, 1, 0, 0], [1, 1, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]],
        x_offset: (BOARD_WIDTH as f64 / 2.0) - 1.0,
        y_offset: 0.0
    },
    Tetromino {
        name: Shape::S,
        blocks: [[0, 0, 0, 0], [0, 1, 1, 0], [1, 1, 0, 0], [0, 0, 0, 0]],
        x_offset: (BOARD_WIDTH as f64 / 2.0) - 2.0,
        y_offset: 0.0
    },
    Tetromino {
        name: Shape::T,
        blocks: [[0, 0, 0, 0], [1, 1, 1, 0], [0, 1, 0, 0], [0, 0, 0, 0]],
        x_offset: (BOARD_WIDTH as f64 / 2.0) - 2.0,
        y_offset: 0.0
    },
    Tetromino {
        name: Shape::Z,
        blocks: [[0, 0, 0, 0], [1, 1, 0, 0], [0, 1, 1, 0], [0, 0, 0, 0]],
        x_offset: (BOARD_WIDTH as f64 / 2.0) - 2.0,
        y_offset: 0.0
    },  
];

#[derive(PartialEq, Debug, Clone, Copy)]
pub enum Shape {
    I,
    O,
    T,
    S,
    Z,
    J,
    L
}

#[derive(Debug, Clone, Copy)]
pub struct Tetromino {
    pub name: Shape,
    pub blocks: [[u8; 4]; 4],
    pub x_offset: f64, // offset (in block cell units) of the top left cell
    pub y_offset: f64
}

impl Tetromino {
    pub fn rotate_right(&mut self) {
        if self.name == Shape::O {
            return
        }
        let mut new_blocks = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]];
        for (r, row) in self.blocks.iter().enumerate() {
{'fraction_non_alphanumeric': 0.19971160778658975, 'fraction_numerical': 0.0874789714011055, 'mean_word_length': 1.8390177353342427, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '597566', 'n_tokens_mistral': 2072, 'n_tokens_neox': 1803, 'n_words': 568}