forked from Ramblurr/scriptbots
-
Notifications
You must be signed in to change notification settings - Fork 44
/
World.h
71 lines (54 loc) · 1.44 KB
/
World.h
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
60
61
62
63
64
65
66
67
68
69
70
71
#ifndef WORLD_H
#define WORLD_H
#include "View.h"
#include "Agent.h"
#include "settings.h"
#include <vector>
class World
{
public:
World();
~World();
void update();
void reset();
void draw(View* view, bool drawfood);
bool isClosed() const;
void setClosed(bool close);
/**
* Returns the number of herbivores and
* carnivores in the world.
* first : num herbs
* second : num carns
*/
std::pair<int,int> numHerbCarnivores() const;
int numAgents() const;
int epoch() const;
//mouse interaction
void processMouse(int button, int state, int x, int y);
void addNewByCrossover();
void addRandomBots(int num);
void addCarnivore();
void addHerbivore();
void positionOfInterest(int type, float &xi, float &yi);
std::vector<int> numCarnivore;
std::vector<int> numHerbivore;
int ptr;
private:
void setInputs();
void processOutputs();
void brainsTick(); //takes in[] to out[] for every agent
void writeReport();
void reproduce(int ai, float MR, float MR2);
int modcounter;
int current_epoch;
int idcounter;
std::vector<Agent> agents;
// food
int FW;
int FH;
int fx;
int fy;
float food[conf::WIDTH/conf::CZ][conf::HEIGHT/conf::CZ];
bool CLOSED; //if environment is closed, then no random bots are added per time interval
};
#endif // WORLD_H