fn initialize(&mut self, dimensions: graphics::Rect) {
        // Create a new dimensions object for the grid of cells (60 px removed for the banner)
        let griddimensions = graphics::Rect::new(0.0, 0.0, dimensions.w, dimensions.h - 60.0);
        // Set the grid dimensions to the grid 
        self.grid.setdimensions(griddimensions);
        
        // Check the value of the initial state field
        match self.initialstate.as_str() {
            // Default initial state (random-balanced)
            "default" => {
                // Set the initial state string of the automaton
                self.initialstate = "Empty".to_string();

                // Create a grid of random cells with a balanced ratio of dead and alive cells
                let randomgrid = CellGrid::<BinaryCell>::generate_empty_grid(self.cellsize, griddimensions);
                // Set the generated grid to the automaton grid
                self.grid.setgrid(randomgrid);

                self.ant = Some(Turmite::new(&self.grid));
            },

            // Invalid initial state
            _ => {
                // Print an error and exit
                eprintln!("[error] invalid initial state for 'gameoflife'");
                std::process::exit(0);
            }
        }
    }
/// A method that initializes the automaton for the given dimensions.
A method that initializes the automaton for the given dimensions.
A method that initializes the automaton for the given dimensions .
fn initialize(&mut self, dimensions: graphics::Rect) {
        // Create a new dimensions object for the grid of cells (60 px removed for the banner)
        let griddimensions = graphics::Rect::new(0.0, 0.0, dimensions.w, dimensions.h - 60.0);
        // Set the grid dimensions to the grid 
        self.grid.setdimensions(griddimensions);
        // Check the value of the initial state field
        match self.initialstate.as_str() {
            // Default initial state (random-balanced)
            "default" => {
                // Set the initial state string of the automaton
                self.initialstate = "Empty".to_string();
                // Create a grid of random cells with a balanced ratio of dead and alive cells
                let randomgrid = CellGrid::<BinaryCell>::generate_empty_grid(self.cellsize, griddimensions);
                // Set the generated grid to the automaton grid
                self.grid.setgrid(randomgrid);
                self.ant = Some(Turmite::new(&self.grid));
            },
            // Invalid initial state
            _ => {
                // Print an error and exit
                eprintln!("[error] invalid initial state for 'gameoflife'");
                std::process::exit(0);
            }
        }
    }
fn initialize ( & mut self , dimensions : graphics :: Rect ) { // Create a new dimensions object for the grid of cells (60 px removed for the banner) let griddimensions = graphics :: Rect :: new ( 0.0 , 0.0 , dimensions . w , dimensions . h - 60.0 ) ; // Set the grid dimensions to the grid  self . grid . setdimensions ( griddimensions ) ; // Check the value of the initial state field match self . initialstate . as_str ( ) { // Default initial state (random-balanced) " " => { // Set the initial state string of the automaton self . initialstate = " " . to_string ( ) ; // Create a grid of random cells with a balanced ratio of dead and alive cells let randomgrid = CellGrid :: < BinaryCell > :: generate_empty_grid ( self . cellsize , griddimensions ) ; // Set the generated grid to the automaton grid self . grid . setgrid ( randomgrid ) ; self . ant = Some ( Turmite :: new ( & self . grid ) ) ; } , // Invalid initial state _ => { // Print an error and exit eprintln ! ( " " ) ; std :: process :: exit ( 0 ) ; } } }
A method that initializes the automaton for the given dimensions.
A method that initializes the automaton for the given dimensions .
&mut self
dimensions
graphics::Rect
&mut self
dimensions
graphics::Rect