~athorp96/conway.rs

ref: 63995b3124f8e1724bb46b13c9110fbc6378887a conway.rs/src/main.rs -rw-r--r-- 556 bytes
63995b31Andrew Thorp Minor refactor 1 year, 5 days ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
use std::{thread, time};

mod conway;

use conway::board::Board;
use conway::cell::CellState;

fn sleep(time_ms: usize) {
    let sleep_time = time::Duration::from_millis(time_ms as u64);
    thread::sleep(sleep_time);
}

fn main() {
    let mut b = Board::new(10, 10);

    b.set(0, 0, CellState::Alive);
    b.set(1, 1, CellState::Alive);
    b.set(1, 2, CellState::Alive);
    b.set(2, 0, CellState::Alive);
    b.set(2, 1, CellState::Alive);

    for i in 0..=30 {
        println!("Board: {}\n{}", i, b);
        b.step();
        sleep(100);
    }
}