Compare commits
3 commits
TheLie0-ge
...
master
Author | SHA1 | Date | |
---|---|---|---|
|
07f3f9f3bc | ||
|
58b589af13 | ||
|
4a4edfdf51 |
1 changed files with 10 additions and 0 deletions
10
src/main.rs
10
src/main.rs
|
@ -2,18 +2,25 @@ extern crate console;
|
|||
extern crate rand;
|
||||
|
||||
use console::Term;
|
||||
use std::thread::sleep;
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
fn main() {
|
||||
let cutoff: f32 = 0.3;
|
||||
let frame_wait_time = Duration::from_millis(70);
|
||||
let term = Term::stdout();
|
||||
|
||||
let mut game = GameOfLife::new(255, 255, cutoff);
|
||||
game.print_to_console(&term);
|
||||
let mut now = Instant::now();
|
||||
sleep(frame_wait_time);
|
||||
loop {
|
||||
game.update();
|
||||
if game.print_to_console(&term) == 0 {
|
||||
game = GameOfLife::new(255, 255, cutoff);
|
||||
}
|
||||
now = Instant::now();
|
||||
sleep(frame_wait_time);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -112,6 +119,9 @@ fn random_one_or_zero_with_cutoff_point(cutoff: f32) -> u16 {
|
|||
|
||||
fn get_movement_score(cell: u16) -> usize {
|
||||
if (cell & 0b0000000001111110) == ((cell & 0b0001111110000000) >> 6) {
|
||||
/*Checking the matching the last six states with the six before to find
|
||||
out whether the cell is stagnant. The number six is chosen because it
|
||||
encompasses all regular patterns of size 2, 3 and 6.*/
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
|
|
Loading…
Reference in a new issue