Mercurial > hg > tweakathon2ios
comparison TrainingScoreManager.h @ 38:fea11c3d1d94
tweaking endlessly
author | Robert Tubb <rt300@eecs.qmul.ac.uk> |
---|---|
date | Thu, 04 Dec 2014 17:03:01 +0000 |
parents | 52dbd5b4cfa9 |
children | 96ff7b41923a |
comparison
equal
deleted
inserted
replaced
37:52dbd5b4cfa9 | 38:fea11c3d1d94 |
---|---|
33 | 33 |
34 // equiv of score bit of testController | 34 // equiv of score bit of testController |
35 public: | 35 public: |
36 TrainingScoreManager(){ | 36 TrainingScoreManager(){ |
37 totalScored = 0; | 37 totalScored = 0; |
38 }; | |
39 int getBandForDistance(float dist) const{ | |
40 int band = -1; | |
41 auto dimComp = sqrt(TOTAL_NUM_PARAMS); | |
42 if (dist < TARGET_SCORE_CC_BAND*dimComp){ | |
43 | |
44 band = 1; | |
45 | |
46 }else if (dist < TARGET_SCORE_CC_BAND*2*dimComp){ | |
47 | |
48 band = 2; | |
49 | |
50 }else if (dist < TARGET_SCORE_CC_BAND*3*dimComp){ | |
51 | |
52 band = 3; | |
53 | |
54 }else if (dist < TARGET_SCORE_CC_BAND*4*dimComp){ | |
55 | |
56 band = 4; | |
57 | |
58 }else if (dist < TARGET_SCORE_CC_BAND*6*dimComp){ // 30 | |
59 | |
60 band = 5; | |
61 | |
62 | |
63 }else if (dist < TARGET_SCORE_CC_BAND*9*dimComp){ // 45 | |
64 | |
65 band = 6; | |
66 | |
67 | |
68 }else{ | |
69 | |
70 band = 7; | |
71 | |
72 | |
73 } | |
74 return band; | |
75 }; | |
76 | |
77 string getMessageForBand(int band) const{ | |
78 stringstream msg; | |
79 if (band == 1){ | |
80 | |
81 msg << "DOUBLE BULLSEYE!" << endl; | |
82 | |
83 | |
84 }else if (band == 2){ | |
85 | |
86 | |
87 msg << "SINGLE BULLSEYE!" << endl; | |
88 | |
89 }else if (band == 3){ | |
90 | |
91 msg << "CLOSE..." << endl; | |
92 | |
93 }else if (band == 4){ | |
94 | |
95 msg << "OK...ISH" << endl; | |
96 | |
97 }else if (band == 5){ // 30 | |
98 | |
99 msg << "MEDIOCRE" << endl; | |
100 | |
101 }else if (band == 6){ // 45 | |
102 | |
103 msg << "POOR..." << endl; | |
104 | |
105 }else{ | |
106 | |
107 msg << "MISSED COMPLETELY!" << endl; | |
108 | |
109 | |
110 } | |
111 return msg.str(); | |
38 } | 112 } |
39 | 113 ofColor getColorForBand(int band) const { |
114 | |
115 | |
116 ofColor c; | |
117 if(band == 1){ | |
118 | |
119 c = ofColor(255,255,0,255); // yellow 1 | |
120 }else if(band == 2){ | |
121 c = ofColor(255,0,0,255); // red 2 | |
122 }else if(band == 3){ | |
123 c = ofColor(45,45,255,255); // blue 3 | |
124 }else if(band == 4){ | |
125 c = ofColor(0,255,0,255); // green 4 | |
126 }else{ | |
127 c = ofColor(123,123,123,255); // grey worst | |
128 } | |
129 return c; | |
130 }; | |
40 TrainingTestResult getScoreForAnswer(vector<int> targetParams, | 131 TrainingTestResult getScoreForAnswer(vector<int> targetParams, |
41 vector<int> startPosition, | 132 vector<int> startPosition, |
42 vector<int> answer, | 133 vector<int> answer, |
43 int timeAllowed, | 134 int timeAllowed, |
44 int difficulty, | 135 int difficulty, |
59 if (dist <= 0) dist = 0.001; | 150 if (dist <= 0) dist = 0.001; |
60 float TP = calculateThroughput(TOTAL_NUM_PARAMS, dist, initDist, timeAllowed/1000.); | 151 float TP = calculateThroughput(TOTAL_NUM_PARAMS, dist, initDist, timeAllowed/1000.); |
61 cout << "Preset index " << presetIndex << endl; | 152 cout << "Preset index " << presetIndex << endl; |
62 cout << "whichInSequence " << whichInSequence << endl; | 153 cout << "whichInSequence " << whichInSequence << endl; |
63 | 154 |
64 auto dimComp = sqrt(TOTAL_NUM_PARAMS); | 155 int band = getBandForDistance(dist); |
65 int band = -1; | 156 |
66 if (dist < TARGET_SCORE_CC_BAND*dimComp){ | 157 msg << getMessageForBand(band) << endl; |
67 | 158 msg << "Distance: " << dist << endl; |
68 band = 1; | |
69 | |
70 msg << "DOUBLE BULLSEYE!" << endl; | |
71 | |
72 | |
73 }else if (dist < TARGET_SCORE_CC_BAND*2*dimComp){ | |
74 | |
75 band = 2; | |
76 | |
77 msg << "SINGLE BULLSEYE!" << endl; | |
78 | |
79 }else if (dist < TARGET_SCORE_CC_BAND*3*dimComp){ | |
80 | |
81 band = 3; | |
82 msg << "CLOSE..." << endl; | |
83 | |
84 }else if (dist < TARGET_SCORE_CC_BAND*4*dimComp){ | |
85 | |
86 band = 4; | |
87 msg << "OK...ISH" << endl; | |
88 | |
89 }else if (dist < TARGET_SCORE_CC_BAND*6*dimComp){ // 30 | |
90 | |
91 band = 5; | |
92 msg << "MEDIOCRE" << endl; | |
93 | |
94 }else if (dist < TARGET_SCORE_CC_BAND*9*dimComp){ // 45 | |
95 | |
96 band = 6; | |
97 msg << "POOR..." << endl; | |
98 | |
99 }else{ | |
100 | |
101 band = 7; | |
102 msg << "MISSED COMPLETELY!" << endl; | |
103 | |
104 | |
105 } | |
106 msg << "Distance from target: " << dist << endl; | |
107 msg << "Score: " << round(TP*10) << endl; | 159 msg << "Score: " << round(TP*10) << endl; |
108 msg << "-----" << endl; | 160 msg << "-----" << endl; |
109 msg << "Time allowed: " << timeAllowed/1000.0 << endl; | 161 msg << "Time allowed: " << timeAllowed/1000.0 << endl; |
110 | |
111 msg << "-----" << endl; | 162 msg << "-----" << endl; |
112 | 163 |
113 result.realDistanceToTarget = dist; | 164 result.realDistanceToTarget = dist; |
114 result.targetBandHit = band; // eg bullseye = 0 edge = 7 | 165 result.targetBandHit = band; // eg bullseye = 0 edge = 7 |
115 result.timeAllowed = timeAllowed; | 166 result.timeAllowed = timeAllowed; |
116 result.score = int(round(TP*10.0)); | 167 result.score = int(round(TP*10.0)); |
117 result.displayText = msg.str(); | 168 result.displayText = msg.str(); |
118 result.difficultyLevel = difficulty; | 169 result.difficultyLevel = difficulty; |
119 | 170 result.colorBand = getColorForBand(band); |
120 | |
121 ofColor c; | |
122 if(result.targetBandHit == 1){ | |
123 | |
124 c = ofColor(255,255,0,255); // yellow 1 | |
125 }else if(result.targetBandHit == 2){ | |
126 c = ofColor(255,0,0,255); // red 2 | |
127 }else if(result.targetBandHit == 3){ | |
128 c = ofColor(45,45,255,255); // blue 3 | |
129 }else if(result.targetBandHit == 4){ | |
130 c = ofColor(0,255,0,255); // green 4 | |
131 }else{ | |
132 c = ofColor(123,123,123,255); // grey worst | |
133 } | |
134 result.colorBand = c; | |
135 | 171 |
136 if(result.score > 0) totalScored += result.score; | 172 if(result.score > 0) totalScored += result.score; |
137 | 173 |
138 | 174 |
139 vector<int> details; | 175 vector<int> details; |