-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsimulationwindow.h
More file actions
108 lines (79 loc) · 2.46 KB
/
simulationwindow.h
File metadata and controls
108 lines (79 loc) · 2.46 KB
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
#ifndef SIMULATIONWINDOW_H
#define SIMULATIONWINDOW_H
#include <QMainWindow>
#include "animal.h" //Includes Vector2
#include <QtCharts>
#include <thread>
#include <atomic>
namespace Ui {
class SimulationWindow;
}
class SimulationWindow : public QMainWindow
{
Q_OBJECT
public:
explicit SimulationWindow(QWidget *parent = 0);
~SimulationWindow();
public slots:
void updateEnviroment();
private slots:
void on_addFox_clicked();
void on_addRabbit_clicked();
void on_addAverageFox_clicked();
void on_addAverageRabbit_clicked();
void on_StartButton_clicked();
void on_PauseButton_clicked();
void on_ResetButton_clicked();
void on_SimulationSpeed_valueChanged(int value);
private:
Ui::SimulationWindow *ui;
Enviroment enviroment;
void initilizeEnviroment();
QTimer * timer;
//Charts
QChart * foxPopulation;
QChart * foxSpeed;
QChart * foxSenseRadius;
QChart * foxEnergyEficiency;
QLineSeries * foxPopulationS;
QLineSeries * foxSpeedS;
QLineSeries * foxSenseRadiusS;
QLineSeries * foxEnergyEficiencyS;
unsigned int foxPopulationMax = 0;
unsigned int foxSpeedMax = 0;
unsigned int foxSenseRadiusMax = 0;
unsigned int foxEnergyEficiencyMax = 0;
QChart * rabbitPopulation;
QChart * rabbitSpeed;
QChart * rabbitSenseRadius;
QChart * rabbitEnergyEfficiency;
QLineSeries * rabbitPopulationS;
QLineSeries * rabbitSpeedS;
QLineSeries * rabbitSenseRadiusS;
QLineSeries * rabbitEnergyEfficiencyS;
unsigned int rabbitPopulationMax = 0;
unsigned int rabbitSpeedMax = 0;
unsigned int rabbitSenseRadiusMax = 0;
unsigned int rabbitEnergyEfficiencyMax = 0;
QChart * totalPlants;
QChart * newPlantsPerSteep;
QLineSeries * totalPlantsS;
QLineSeries * newPlantsPerSteepS;
unsigned int totalPlantsMax = 0;
unsigned int newPlantsPerSteepMax = 0;
bool isPause = true;
void updateStatistics(const EnviromentStatistics &stats,const unsigned int timeStep);
Gens averageFoxGens;
Gens averageRabbitGens;
unsigned int timeStepCount = 0;
const uint threadCount = std::thread::hardware_concurrency();
std::vector<std::thread> threadPool;
std::mutex accessBoolVecs;
std::vector<bool> threadPoolFinished;
std::vector<bool> startExec;
std::atomic<bool> stopExec;
std::function<void(uint)> threadFun;
void initThreadPool();
bool allThreadsFinished()const;
};
#endif // SIMULATIONWINDOW_H