-
Notifications
You must be signed in to change notification settings - Fork 0
/
population.hpp
88 lines (75 loc) · 2.01 KB
/
population.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
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
#ifndef POPULATION_H
#define POPULATION_H
#include <SFML/Graphics.hpp>
#include <vector>
#include <cmath>
#include <random>
#include <iostream>
class Person{
public:
// x and y positions
float x;
float y;
// get box for drawing to screen
sf::RectangleShape getBox() {
return this->box;
};
Person(float x, float y);
Person(const Person& rhs);
Person& operator=(const Person& rhs) {return *this;};
int findNewPosition(std::vector<Person> neighbours);
void setPosition(float x, float y);
void setIndex(int i);
void setRace(bool race);
void setEmpty(bool e);
void setHappiness(std::vector<Person> neighbours);
void setTolerance(float t);
void update();
std::tuple<float, float> getPosition() const {
return std::make_tuple(this->x, this->y);
};
float getWidth() const {
return this->width;
};
float getHeight() const {
return this->height;
};
int getIndex() const {
return this->index;
};
bool getRace() const {
return this->race;
};
bool getEmpty() const {
return this->empty;
};
float getHappiness() const {
return this->happiness;
};
float getTolerance() const {
return this->tolerance;
};
private:
int index;
sf::RectangleShape box;
bool empty = false;
bool race = false;
float happiness = NAN;
float tolerance = 0;
float width;
float height;
};
class Population{
public:
std::vector<Person> population;
Population(float w, float h);
std::vector<Person> findNeighbours(int i);
void move(int i);
Person* getPerson(int i);
void printNeighbours(int i);
private:
int gridSize = 100;
int numOfRows;
int numOfColumns;
};
#endif