~athorp96/conway.rs

ref: bf091e801b8a9bad1f600f64ac7a29b4b06d546f conway.rs/src/main.rs -rw-r--r-- 551 bytes
bf091e80Andrew Thorp Initial commit 1 year, 8 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::conway::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..50 {
        println!("Board:\n{}", b);
        b.step();
        sleep(100);
    }
}