You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
916 B
39 lines
916 B
#![feature(trait_alias)]
|
|
|
|
use std::io::{self, BufRead};
|
|
|
|
mod binary;
|
|
mod board_metadata;
|
|
mod game;
|
|
mod rules;
|
|
mod rules_easy;
|
|
|
|
use binary::State;
|
|
use game::Game;
|
|
use rules::Rules;
|
|
use rules_easy::RulesEasy;
|
|
|
|
fn solve<T: Rules>(lines: &[String]) {
|
|
let mut game = Game::from_input::<T>(&lines);
|
|
|
|
//game.print_board();
|
|
|
|
for i in 1.. {
|
|
let changes_count = game.next_step();
|
|
println!("Iteration {}; changed cells: {}; alive_cells: {}", i, changes_count, game.get_count_of_cells_for_state(State::Alive));
|
|
//game.print_board();
|
|
if changes_count == 0 {
|
|
break;
|
|
}
|
|
}
|
|
|
|
//game.print_board();
|
|
println!("Board stabilized at {} occupied seats", game.get_count_of_cells_for_state(State::Alive));
|
|
}
|
|
|
|
fn main() {
|
|
let stdin = io::stdin();
|
|
let lines: Vec<_> = stdin.lock().lines().map(|line| line.unwrap()).collect();
|
|
|
|
solve::<RulesEasy>(&lines);
|
|
}
|
|
|