full sim
This commit is contained in:
parent
ac03021b28
commit
211db6da03
2 changed files with 18 additions and 21 deletions
|
|
@ -5,22 +5,26 @@ pub mod weights;
|
||||||
use model::*;
|
use model::*;
|
||||||
use weights::{ColorWeights, Config};
|
use weights::{ColorWeights, Config};
|
||||||
|
|
||||||
use std::fs;
|
use std::fs::{self, OpenOptions};
|
||||||
|
use std::io::prelude::*;
|
||||||
|
|
||||||
use rayon::prelude::*;
|
use rayon::prelude::*;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let config = parse_config("config.toml").unwrap();
|
let config = parse_config("config.toml").unwrap();
|
||||||
|
|
||||||
let mut res: Vec<(ColorWeights, Vec<f64>)> = Vec::new();
|
|
||||||
|
|
||||||
for color in gen_possible_color_weights().into_iter() {
|
for color in gen_possible_color_weights().into_iter() {
|
||||||
let val = run_sim(100, &config, &color);
|
let mut file = OpenOptions::new()
|
||||||
println!("{:?} {:?}", color, val);
|
.create(true)
|
||||||
res.push((color, val));
|
.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 {
|
// for i in 0..10 {
|
||||||
// let res = lifeforce_after_upgrades(i, 1000000, &config);
|
// let res = lifeforce_after_upgrades(i, 1000000, &config);
|
||||||
|
|
|
||||||
|
|
@ -5,12 +5,7 @@ use rand::thread_rng;
|
||||||
|
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
use std::fmt::Display;
|
||||||
pub struct UpgradeProbabilities {
|
|
||||||
pub t1_t2: f64,
|
|
||||||
pub t2_t3: f64,
|
|
||||||
pub t3_t4: f64,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
pub struct LifeforceValue {
|
pub struct LifeforceValue {
|
||||||
|
|
@ -43,14 +38,6 @@ pub struct MapMods {
|
||||||
pub pack_size: f64,
|
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)]
|
#[derive(Debug, Deserialize)]
|
||||||
pub struct SeedUpgradeChances {
|
pub struct SeedUpgradeChances {
|
||||||
pub t1: f64,
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue