<commit_before>use std::cell::RefCell;
use std::rc::Rc;

use voodoo::color::ColorValue;
use voodoo::window::{Point, TermCell, Window};

pub struct Program {
    pub position: Point,
    tail: Vec<Point>,
    pub name: String,
    pub abilities: Vec<String>,
}

pub type ProgramRef = Rc<RefCell<Program>>;

impl Program {
    pub fn new(position: Point, name: &str) -> Program {
        Program {
            position: position,
            tail: vec![],
            name: name.to_owned(),
            abilities: vec![],
        }
    }

    pub fn move_to(&mut self, point: Point) {
        self.tail.push(self.position);
        self.position = point;
    }

    pub fn display_color(&self, color: ColorValue, window: &mut Window) {
        let mut tc: TermCell = '◘'.into();
        tc.bg = Some(color);
        window.put_at(self.position, tc);
        for point in self.tail.iter() {
            window.put_at(*point, tc);
        }
    }

    pub fn intersects(&self, point: Point) -> bool {
        for t in self.tail.iter() {
            if *t == point {
                return true;
            }
        }
        self.position == point
    }
}<commit_msg>feat: limit size of tail<commit_after>use std::cell::RefCell;
use std::rc::Rc;

use voodoo::color::ColorValue;
use voodoo::window::{Point, TermCell, Window};

pub struct Program {
    pub position: Point,
    tail: Vec<Point>,
    pub name: String,
    pub abilities: Vec<String>,
    pub max_tail: usize,
}

pub type ProgramRef = Rc<RefCell<Program>>;

impl Program {
    pub fn new(position: Point, name: &str) -> Program {
        Program {
            position: position,
            tail: vec![],
            name: name.to_owned(),
            abilities: vec![],
            max_tail: 4,
        }
    }

    pub fn move_to(&mut self, point: Point) {
        self.tail.push(self.position);
        if self.tail.len() >= self.max_tail {
            self.tail.remove(0);
        }
        self.position = point;
    }

    pub fn display_color(&self, color: ColorValue, window: &mut Window) {
        let mut tc: TermCell = '◘'.into();
        tc.bg = Some(color);
        window.put_at(self.position, tc);
        for point in self.tail.iter() {
            window.put_at(*point, tc);
        }
    }

    pub fn intersects(&self, point: Point) -> bool {
        for t in self.tail.iter() {
            if *t == point {
                return true;
            }
        }
        self.position == point
    }
}
{'fraction_non_alphanumeric': 0.13669354838709677, 'fraction_numerical': 0.0008064516129032258, 'mean_word_length': 1.9326241134751774, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 16, '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': '7269931', 'n_tokens_mistral': 783, 'n_tokens_neox': 777, 'n_words': 203}