-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenvironment.hpp
58 lines (50 loc) · 1.03 KB
/
environment.hpp
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
#pragma once
#include <SDL2/SDL.h>
#include <vector>
#include "food.hpp"
#include "neural_network.hpp"
class Environment;
class Bug {
public:
int x, y;
int energy;
int age;
int generation;
bool dead;
NeuralNetwork brain;
Bug();
void generate_brain(int inputs, int outputs, int hidden_neurons);
void mutate_brain(double mutation_factor);
void draw(SDL_Renderer* rend);
void cycle(Environment* env);
void clear_brain();
};
class Environment {
public:
int width, height;
SDL_Window* win;
SDL_Renderer* rend;
std::vector<Bug*> bugs;
std::vector<Bug*> new_bugs;
std::vector<Food> foods;
class {
public:
int generation;
int total_population;
int total_energy;
int total_age;
int total_generation;
int total_neurons;
int max_energy;
int max_age;
int max_generation;
int max_neurons;
int min_energy;
int min_age;
int min_generation;
int min_neurons;
} state;
void draw();
void cycle();
Environment(int width, int height, int food, int bugs);
};