This commit is contained in:
2026-01-26 12:22:44 +01:00
parent 1b32a91b0d
commit 66933433d1
14 changed files with 1030 additions and 884 deletions

View File

@@ -1,6 +1,6 @@
use rand::rngs::StdRng;
use rand::SeedableRng;
use cagire::forth::{Dictionary, Forth, Rng, StepContext, Value, Variables};
use cagire::forth::{Dictionary, EmissionCounter, Forth, Rng, StepContext, Value, Variables};
use std::collections::HashMap;
use std::sync::{Arc, Mutex};
@@ -46,6 +46,14 @@ pub fn forth_seeded(seed: u64) -> Forth {
Forth::new(new_vars(), new_dict(), seeded_rng(seed))
}
pub fn new_emission_counter() -> EmissionCounter {
Arc::new(Mutex::new(0))
}
pub fn forth_with_counter(counter: EmissionCounter) -> Forth {
Forth::new_with_counter(new_vars(), new_dict(), seeded_rng(42), counter)
}
pub fn run(script: &str) -> Forth {
let f = forth();
f.evaluate(script, &default_ctx()).unwrap();