-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
59 lines (52 loc) · 2.16 KB
/
main.cpp
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
48
49
50
51
52
53
54
55
56
57
58
59
#include <ctime>
#include <iostream>
#include "environment.hpp"
int main() {
srand(time(NULL)); // for testing
Environment env(1000, 500, 1000, 10000);
bool close = false;
while (!close) {
env.cycle();
env.draw();
if (env.state.total_population == 0) {
std::cout << "Population died out" << std::endl;
close = true;
}
if (env.state.generation % 10 == 0 && env.state.total_population > 0)
std::cout << "======= STATS =======" << std::endl
<< "Population: " << env.state.total_population << std::endl
<< "Max Energy: " << env.state.max_energy << std::endl
<< "Average Energy: " << env.state.total_energy / (double)env.state.total_population
<< std::endl
<< "Min Energy: " << env.state.min_energy << std::endl
<< "Max Age: " << env.state.max_age << std::endl
<< "Average Age: " << env.state.total_age / (double)env.state.total_population
<< std::endl
<< "Min Age: " << env.state.min_age << std::endl
<< "Max Generation: " << env.state.max_generation << std::endl
<< "Average Generation: "
<< env.state.total_generation / (double)env.state.total_population << std::endl
<< "Min Generation: " << env.state.min_generation << std::endl
<< "Max Neurons: " << env.state.max_neurons << std::endl
<< "Average Neurons: "
<< env.state.total_neurons / (double)env.state.total_population << std::endl
<< "Min Neurons: " << env.state.min_neurons << std::endl
<< "World Age: " << env.state.generation << std::endl
<< "=====================" << std::endl;
SDL_RenderPresent(env.rend);
SDL_Event event;
while (SDL_PollEvent(&event)) {
switch (event.type) {
case SDL_QUIT:
close = 1;
break;
}
}
}
// Bug *bug = new Bug;
// bug->generate_brain(5, 4, 50);
// std::cout << bug->brain.hidden.size() << std::endl;
// bug->mutate_brain(0.5);
// std::cout << bug->brain.hidden.size() << std::endl;
return 0;
}