-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathblob.h
120 lines (70 loc) · 1.91 KB
/
blob.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#ifndef BLOB_H
#define BLOB_H
#include <iostream>
#include <string>
#include <optional>
#include <vector>
#include <array>
#include "thing.h"
#include "food.h"
extern int g_mutationProb;
class Blob : public Thing
{
protected:
double m_nativeEnergy;
double m_energy = m_nativeEnergy;
double m_sense;
double m_speed;
double m_size;
int m_foodEaten = 0;
int m_mapSize;
int m_name;
std::array<double, 2> m_stepTarget;
public:
Blob();
Blob(double nativeEnergy, double size, double speed, double sense);
int getName();
void setName(int name);
double getSense();
void setSense(double x);
double getSpeed();
void setSpeed(double x);
double getSize();
void setSize(double x);
double getCost();
double getEnergy();
void reduceEnergy();
void setEnergy(double x);
int getMapSize();
void setMapSize(int x);
int getFoodEaten();
void setFoodEaten(int x);
void sleep();
void stepNorth();
void stepSouth();
void stepEast();
void stepWest();
void stepEastOrWest();
void stepNorthOrSouth();
void randomStep();
void stepTowards(Thing &thing);
void stepAway(Thing &thing);
double distToObject(Thing &object);
bool atHome();
void goHome();
void searchPattern();
double distToEdge();
bool hasSurplusStamina();
void huntOrRun(std::vector<Blob> &blobArray, std::vector<Food> &foodArray);
std::optional<int> lookForFood(std::vector<Food> &foodArray);
std::optional<int> lookForPrey(std::vector<Blob> &blobArray);
std::optional<int> lookForPredator(std::vector<Blob> &blobArray);
std::optional<int> tryToEat(std::vector<Blob> &blobArray, std::vector<Food> &foodArray);
void mutate();
std::optional<Blob> tryToReplicate();
void setStepTarget(double x, double y);
std::array<double, 2>& getStepTarget();
void continueStep();
bool finishedStep();
};
#endif