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
43
44
45
46
47
#[cfg(test)]
#[macro_use]
extern crate approx;
use serde::Deserialize;
mod genetic;
pub(crate) mod network;
mod neuron;
pub mod randomizer;
pub mod simulating_world;
pub mod simulation;
pub mod specimen;
pub mod training_ground;
const BIAS_VALUE: f64 = 1.0;
const MINIMUM_POPULATION_SIZE: usize = 4;
#[derive(Clone, Debug, Deserialize)]
pub struct Specimen {
pub brain: network::NetworkLayout,
pub fitness: f64,
}
impl Specimen {
pub fn from_json(j: &str) -> Self {
Specimen {
fitness: 0.0,
brain: serde_json::from_str(j).unwrap(),
}
}
}