3 releases
new 1.0.0-alpha.3 | Jan 4, 2025 |
---|---|
1.0.0-alpha.2 | Jan 2, 2025 |
1.0.0-alpha.1 | Dec 29, 2024 |
#50 in Simulation
440 downloads per month
30KB
471 lines
FBSim Core
A library for american football simulation
Overview
In its initial iteration, this crate provides utilities for simulating american football leagues at the box score level. It is based on the four regression models derived in this repository.
Usage
Adding via Cargo
To add the package to your project, run the following from your project directory.
cargo add fbsim-core
Box score simulator
To simulate a game using the box score simulator, one might replicate the following example. Note that FootballTeam
and BoxScore
both derive the serde Serialize
and Deserialize
traits and thus may be instantiated from JSON.
use fbsim_core::sim::BoxScoreSimulator;
use fbsim_core::team::FootballTeam;
// Instantiate the simulator
let my_box_score_sim = BoxScoreSimulator::new();
// Instantiate the home and away team
let home_team = FootballTeam::from_properties(
"Home Team",
75,
67
).unwrap();
let away_team = FootballTeam::from_properties(
"Away Team",
88,
95
).unwrap();
// Instantiate an RNG and simulate
let mut rng = rand::thread_rng();
let my_box_score = my_box_score_sim.sim(
&home_team,
&away_team,
&mut rng
);
println!("{}", my_box_score);
Dependencies
~1–32MB
~488K SLoC