1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
use dice_forge::Equation;

fn main() {
    let my_die = Equation::new("d100").expect("handle the error in real code");
    let mut results: u64 = 0;
    let mut hit_low = false;
    let mut hit_high = false;
    let mut highest: u64 = 0;
    let mut lowest: u64 = 100;
    for _n in 0..10000 {
        let rez = my_die.roll().unwrap();
        if rez == 1 {
            hit_low = true;
        } else if rez == 100 {
            hit_high = true;
        }
        if (rez as u64) < lowest {
            lowest = rez as u64;
        }
        if (rez as u64) > highest {
            highest = rez as u64;
        }
        results += my_die.roll().unwrap() as u64;
    }
    println!("average: {}", results / 10000);
    println!("Hit High: {}, number: {}", hit_high, highest);
    println!("Hit Low: {}, number: {}", hit_low, lowest);
    println!("single roll {}", my_die.roll().unwrap());
}