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
30
31
32
33
34
35
36
37
38
39
40
41
42
use rand::{Rng, thread_rng};
use environment::Space;
#[derive(Debug, Clone, Copy)]
pub struct Range {
low: f64,
high: f64
}
impl Space for Range {
type Element = f64;
fn sample(&self) -> f64 {
let mut rng = thread_rng();
rng.gen_range(self.low, self.high)
}
}
impl Default for Range {
fn default() -> Range {
Range {
low: 0.0,
high: 1.0
}
}
}
impl Range {
pub fn new(low: f64, high: f64) -> Range {
Range {
low: low,
high: high
}
}
}