From d14bc6ca45357f2e794d3d15663a70ea1a69db5a Mon Sep 17 00:00:00 2001 From: mehbark <terezi@pyrope.net> Date: Mon, 24 Mar 2025 18:17:37 -0400 Subject: [PATCH] viability ceiling, remove unused fields --- src/main.rs | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/main.rs b/src/main.rs index 5bd0ac1..2fca37e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,8 +1,6 @@ -// 2 much noise -#![allow(unused)] -// https://www.smogon.com/stats/2025-02/chaos/gen9ou-0.json +// https://www.smogon.com/stats/2025-02/chaos/ -use std::{collections::HashMap, env, error::Error, fmt, fs::File, path::PathBuf}; +use std::{collections::HashMap, error::Error, fs::File, path::PathBuf}; use clap::Parser; use rusqlite::Connection; @@ -18,13 +16,14 @@ fn main() -> Result<(), Box<dyn Error>> { log::info!("opening connection"); let mut conn = Connection::open(output_file)?; log::info!("creating tables"); - // TODO: checks and counters (actually very cool) + // TODO: checks and counters, specifically KO or switch conn.execute_batch( " BEGIN; CREATE TABLE mon ( name STRING, - usage REAL NOT NULL + usage REAL NOT NULL, + viability_ceiling REAL NOT NULL ); CREATE TABLE ability ( mon STRING, @@ -58,7 +57,12 @@ fn main() -> Result<(), Box<dyn Error>> { log::info!("parsing stats"); let input_file = File::open(input_file)?; let stats: Stats = serde_json::from_reader(input_file)?; - log::info!("{:#?}", stats.info); + log::info!( + "meta: {}: {} battles, cutoff: {}", + stats.info.metagame, + stats.info.battle_count, + stats.info.cutoff + ); for (i, (mon, data)) in stats.data.iter().enumerate() { log::debug!("Processing mon #{i} ({mon})…"); @@ -72,7 +76,10 @@ fn main() -> Result<(), Box<dyn Error>> { // HACK: we get the weighted mon count by summing the ability usage // there's is 1000% a better way to do this let mon_count: f32 = data.abilities.values().sum(); - tx.execute("INSERT INTO mon VALUES (?1, ?2)", (mon, data.usage))?; + tx.execute( + "INSERT INTO mon VALUES (?1, ?2, ?3)", + (mon, data.usage, data.viability_ceiling[1]), + )?; for (ability, count) in &data.abilities { tx.execute( @@ -160,8 +167,6 @@ struct Stats { struct Info { metagame: Box<str>, cutoff: f64, - #[serde(rename = "cutoff deviation")] - cutoff_deviation: i64, #[serde(rename = "number of battles")] battle_count: i64, } @@ -171,13 +176,10 @@ type Counts = HashMap<Box<str>, f32>; #[derive(Debug, Deserialize)] #[serde(rename_all = "PascalCase")] struct Data { - #[serde(rename = "Raw count")] - count: f32, #[serde(rename = "Viability Ceiling")] viability_ceiling: Box<[u32]>, abilities: Counts, items: Counts, - spreads: Counts, moves: Counts, #[serde(rename = "Tera Types")] tera: HashMap<Type, f32>,