diff --git a/crop_rot/src/main.rs b/crop_rot/src/main.rs index 9939c22..d76b793 100644 --- a/crop_rot/src/main.rs +++ b/crop_rot/src/main.rs @@ -5,22 +5,26 @@ pub mod weights; use model::*; use weights::{ColorWeights, Config}; -use std::fs; +use std::fs::{self, OpenOptions}; +use std::io::prelude::*; use rayon::prelude::*; fn main() { let config = parse_config("config.toml").unwrap(); - let mut res: Vec<(ColorWeights, Vec)> = Vec::new(); for color in gen_possible_color_weights().into_iter() { - let val = run_sim(100, &config, &color); - println!("{:?} {:?}", color, val); - res.push((color, val)); - } + let mut file = OpenOptions::new() + .create(true) + .append(true) + .open(format!("data/{}", color)) + .unwrap(); - println!("{}", res); + for res in run_sim(10000, &config, &color).iter() { + writeln!(file, "{res}"); + } + } // for i in 0..10 { // let res = lifeforce_after_upgrades(i, 1000000, &config); diff --git a/crop_rot/src/weights.rs b/crop_rot/src/weights.rs index e60909b..14c8240 100644 --- a/crop_rot/src/weights.rs +++ b/crop_rot/src/weights.rs @@ -5,12 +5,7 @@ use rand::thread_rng; use serde::Deserialize; -#[derive(Debug, Deserialize)] -pub struct UpgradeProbabilities { - pub t1_t2: f64, - pub t2_t3: f64, - pub t3_t4: f64, -} +use std::fmt::Display; #[derive(Debug, Deserialize)] pub struct LifeforceValue { @@ -43,14 +38,6 @@ pub struct MapMods { pub pack_size: f64, } -#[derive(Debug, Deserialize)] -pub struct Weights { - pub upgrade: UpgradeProbabilities, - pub value: LifeforceValue, - pub lifeforce: SeedLifeforce, - pub map_mods: MapMods, -} - #[derive(Debug, Deserialize)] pub struct SeedUpgradeChances { pub t1: f64, @@ -105,3 +92,9 @@ impl ColorWeights { } } } + +impl Display for ColorWeights { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "Y{}_B{}_R{}", self.yellow, self.blue, self.red) + } +}