| Crates.io | fbsim-core |
| lib.rs | fbsim-core |
| version | 1.0.0-beta.1 |
| created_at | 2024-12-29 00:23:53.42014+00 |
| updated_at | 2025-12-29 17:20:16.025528+00 |
| description | A library for american football simulation |
| homepage | https://docs.rs/fbsim-core |
| repository | https://github.com/whatsacomputertho/fbsim-core |
| max_upload_size | |
| id | 1497852 |
| size | 639,998 |
A library for american football simulation
Provides utilities for simulating american football games and leagues. It is based on various statistical models derived in repositories
Here is a quick example of simulating a play-by-play game between two teams.
use fbsim_core::game::context::GameContext;
use fbsim_core::game::play::GameSimulator;
use fbsim_core::team::FootballTeam;
// Instantiate the home and away teams, game context
let home_team = FootballTeam::new();
let away_team = FootballTeam::new();
let context = GameContext::new();
// Instantiate the rng, simulator, and simulate the game
let mut rng = rand::thread_rng();
let sim = GameSimulator::new();
let (game, next_context) = sim.sim(&home_team, &away_team, context, &mut rng).unwrap();
// Print the game log
println!("{}", game);
println!("{} Game over", next_context);
There is also a less in-depth simulator that produces a final score given two teams. Here is a quick example of its usage.
use fbsim_core::game::score::FinalScoreSimulator;
use fbsim_core::team::FootballTeam;
// Instantiate the home and away teams
let home_team = FootballTeam::new();
let away_team = FootballTeam::new();
// Instantiate the rng, simulator, and simulate the game
let mut rng = rand::thread_rng();
let sim = FinalScoreSimulator::new();
let final_score = sim.sim(&home_team, &away_team, &mut rng).unwrap();
// Print the final score
println!("{}", final_score);
To add the package to your project, run the following from your project directory.
cargo add fbsim-core