Skip to content

Commit

Permalink
Add mono_axis implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
be-next committed Jan 2, 2024
1 parent be7f8d4 commit 904f2c6
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions bin/mono_axis.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
use clap::Parser;
use std::fs;
use mono_axis::core::cellular_automaton_builder::CellularAutomatonBuilder;

/// Launch a mono-axis cellular automaton.
#[derive(Parser)]
#[command(author, version, about, long_about = None)]
struct MonoAxis {
/// Path to the configuration file.
#[clap(short, long)]
config: String,

/// Number of steps to perform.
/// If not specified, the automaton will run indefinitely.
/// If specified, the automaton will run for the specified number of steps.
#[clap(short, long)]
steps: Option<usize>,
}

fn main() {
let args = MonoAxis::parse();

if let Err(e) = fs::metadata(&args.config) {
eprintln!("Error : configuration file '{}' doesn't exist. Error : {}", args.config, e);
return;
}

let step = args.steps.unwrap_or(10);

//"examples/example_01/configuration.json"
let cab = CellularAutomatonBuilder::new();
let mut ca = cab.build(&args.config).unwrap();

ca.print();

for _ in 0..step {
ca.step();
ca.print();
}
}

0 comments on commit 904f2c6

Please sign in to comment.