🧪💩 workspace, vanth, varo: Add varo crate and Root struct, update dependencies

- Replaced `bitcode` crate with `bincode` in workspace dependencies.
- Added new crate `varo` for random optimization with `Varo` trait, `Distribution`, and `optimize` function.
- Defined `Root` world struct placeholder in `vanth` crate.
- Created `reference.rs` test module in `vanth` with custom components and events.
- Added TODOs in `varo` for RNG implementation and `optimize` function.
This commit is contained in:
Markus Scully 2025-08-06 16:20:05 +03:00
parent a1cc9b6e04
commit 5614cfe95f
Signed by: mascully
GPG key ID: 93CA5814B698101C
7 changed files with 120 additions and 5 deletions

19
crates/varo/Cargo.toml Normal file
View file

@ -0,0 +1,19 @@
[package]
name = "varo"
version.workspace = true
edition.workspace = true
[lib]
path = "src/lib.rs"
[dependencies]
digest.workspace = true
serde.workspace = true
serde_json.workspace = true
blake3.workspace = true
vanth = { path = "../vanth" }
vanth_derive = { path = "../vanth_derive" }
rand_core.workspace = true
[dev-dependencies]
tempfile = { workspace = true }

49
crates/varo/src/lib.rs Normal file
View file

@ -0,0 +1,49 @@
use rand_core::SeedableRng;
use serde::{Deserialize, Serialize};
use vanth_derive::Vanth;
#[derive(Clone, Debug, Deserialize, Serialize, Vanth)]
pub struct Rng {
// TODO: RNG
}
impl Rng {
// TODO
}
pub trait Varo {
/// Produce a random
fn next(digest: &mut Rng) -> Self;
}
#[derive(Clone, Debug, Deserialize, Serialize, Vanth)]
pub struct Distribution {
/// 0th element is the mean, 1st is the variance etc.
pub moments: Vec<f32>,
}
impl Distribution {
pub fn sample(digest: &mut Rng) -> f32 {
todo!()
}
}
#[derive(Clone, Debug, Deserialize, Serialize, Vanth)]
pub struct Score {
value: f32,
}
#[derive(Clone, Debug, Deserialize, Serialize, Vanth)]
pub struct OptimizationResult {
/// List of pairs of evaluation score and Rng used to generate the value.
values: Vec<(Rng, f32)>
}
pub fn optimize<T: Varo>(evaluator: impl Fn(T) -> Score, rng: &mut Rng, rounds: u32) -> OptimizationResult {
// TODO:
// `for i in 0..rounds`: create a clone of `rng` and feed it `i`.
// Call T::next() and pass it to the evaluator.
// Return a sorted list, highest scores first.
todo!()
}