-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdateFunc.pde
91 lines (70 loc) · 2.34 KB
/
updateFunc.pde
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
void drawOverlap() {
for (int i = 0; i<spd; ++i) {
updateHighestScore();
for (int j = 0; j < pop; ++j) {
rws[j].updateOverlap();
}
}
}
void drawNoOverlap() {
for (int i = 0; i<spd; ++i) {
updateHighestScore();
for (int j = 0; j < pop; ++j) {
rws[j].updateNoOverlap();
}
}
}
void drawGpOverlap() {
for (int i = 0; i<spd; ++i) {
updateHighestScore();
for (int j = 0; j < pop; ++j) {
rws[j].updateGpOverlap();
}
}
if(uC <= 0) checkdead();
}
void consoleLogs() {
print("\n\n\n");
print("\nSpeed : ", spd, " (", spd/fR , ") FrameRate : ", frameRate, " Unvisited cells :", uC);
// --------------------------------------- HIGHEST SCORE PRINTING ---------------------------------- //
if (true) {
String highestScoreName;
if (highestScore.id < name_cpreset.length && highestScore.id != -1) highestScoreName = name_cpreset[highestScore.id];
else highestScoreName = "Unknown";
print("\n\n- Highest Score of this generation - \nId:", highestScore.id, ",", highestScoreName, "\nScore : ",
highestScore.val, ", ", (nf((parseFloat(highestScore.val) * 100) / (cols*rows), 0, 2)), "%");
}
// ------------------------------------------------------------------------------------------------ //
print("\n");
for (int i = 0; i < rws.length && i < rwsInConsole; ++i) {
print("\n[", i+1, "] - Id:", scoresTab[i].id, ",", rws[scoresTab[i].id].name, ", Score : ", scoresTab[i].val, ", ",
(nf((parseFloat(scoresTab[i].val) * 100) / (cols*rows), 0, 2)), "%");
}
int totalScore = 0;
for (int i = 0; i < rws.length; ++i)totalScore += rws[i].score;
print("\n\nTotal Score", totalScore, ", ", (nf((parseFloat(totalScore) * 100) / (cols*rows), 0, 3)), "% of the grid.");
}
void updateHighestScore() {
sortScores();
if (scoresTab[0].val > highestScore.val) {
highestScore.id = scoresTab[0].id;
highestScore.val = scoresTab[0].val;
}
}
int lastHighest = -1;
void dynHighlightFirst() {
if (lastHighest != scoresTab[0].id) {
reDrawGrid();
drawHighlight(scoresTab[0].id);
lastHighest = scoresTab[0].id;
}
drawHighlight(scoresTab[0].id);
}
void checkdead(){
for(int i = 0; i < rws.length; ++i){
if(!rws[i].dead && rws[i].score < (cols*rows) * (dieRatio / 100)){
rws[i].name = "[DEAD]" + rws[i].name;
rws[i].dead = true;
}
}
}