fbsim-core

Crates.iofbsim-core
lib.rsfbsim-core
version1.0.0-beta.1
created_at2024-12-29 00:23:53.42014+00
updated_at2025-12-29 17:20:16.025528+00
descriptionA library for american football simulation
homepagehttps://docs.rs/fbsim-core
repositoryhttps://github.com/whatsacomputertho/fbsim-core
max_upload_size
id1497852
size639,998
(whatsacomputertho)

documentation

README

FBSim Core

Build Test Lint Securty

A library for american football simulation

Overview

Provides utilities for simulating american football games and leagues. It is based on various statistical models derived in repositories

Play-by-play sim

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);

Final score sim

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);

Installing

To add the package to your project, run the following from your project directory.

cargo add fbsim-core
Commit count: 69

cargo fmt