Skip to content

Commit

Permalink
Added birthday when creating new people
Browse files Browse the repository at this point in the history
  • Loading branch information
confunguido committed Nov 4, 2024
1 parent ff8598c commit af72259
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions examples/births-deaths/population_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use serde::Deserialize;
define_rng!(PeopleRng);

static MAX_AGE: u8 = 100;
use rand_distr::Exp;
use rand_distr::{Exp, Uniform};
use serde::Serialize;
use std::fmt;

Expand Down Expand Up @@ -95,7 +95,8 @@ pub fn init(context: &mut Context) {
for _ in 0..parameters.population {
let age: u8 = context.sample_range(PeopleRng, 0..MAX_AGE);
let person = context.create_new_person(age);
context.add_plan(365.0, move |context| {
let birthday = context.sample_distr(PeopleRng, Uniform::new(0.0, 365.0));
context.add_plan(365.0 + birthday, move |context| {
schedule_aging(context, person);
});
}
Expand Down

0 comments on commit af72259

Please sign in to comment.