Mercurial > hg > tweakathon2ios
diff TrainingScoreManager.h @ 35:3b10a26da293
refactoring and log
author | Robert Tubb <rt300@eecs.qmul.ac.uk> |
---|---|
date | Wed, 26 Nov 2014 18:18:20 +0000 |
parents | 3af380769779 |
children | 146033869165 |
line wrap: on
line diff
--- a/TrainingScoreManager.h Wed Nov 26 14:04:05 2014 +0000 +++ b/TrainingScoreManager.h Wed Nov 26 18:18:20 2014 +0000 @@ -11,7 +11,6 @@ #include <iostream> #include "ofMain.h" -//#include "SequenceController.h" #include "algorithms.h" #include "globalVariables.h" #include "eventLogger.h" @@ -27,15 +26,24 @@ ofColor colorBand; string displayText; float bits; + int difficultyLevel; }; class TrainingScoreManager{ // equiv of score bit of testController public: + TrainingScoreManager(){ + totalScored = 0; + } - - TrainingTestResult getScoreForAnswer(vector<int> targetParams, vector<int> startPosition, vector<int> answer, int timeAllowed) { + TrainingTestResult getScoreForAnswer(vector<int> targetParams, + vector<int> startPosition, + vector<int> answer, + int timeAllowed, + int difficulty, + int whichInSequence, + int presetIndex) { TrainingTestResult result; stringstream msg; int score = 0; @@ -44,48 +52,45 @@ //for_each(targetParams.begin(),targetParams.end(),printThing<int>()); float initDist = euclideanDistance(startPosition, answer); float dist = euclideanDistance(targetParams, answer); - float TP = calculateThroughput(TOTAL_NUM_PARAMS, dist, initDist, timeAllowed/1000.); auto dimComp = sqrt(TOTAL_NUM_PARAMS); int band = -1; if (dist < TARGET_SCORE_CC_BAND*dimComp){ - score = 50; + band = 1; msg << "DOUBLE BULLSEYE!" << endl; }else if (dist < TARGET_SCORE_CC_BAND*2*dimComp){ - - score = 25; + band = 2; msg << "SINGLE BULLSEYE!" << endl; }else if (dist < TARGET_SCORE_CC_BAND*3*dimComp){ - - score = 15; + band = 3; msg << "CLOSE..." << endl; }else if (dist < TARGET_SCORE_CC_BAND*4*dimComp){ - score = 5; + band = 4; msg << "OK...ISH" << endl; }else if (dist < TARGET_SCORE_CC_BAND*6*dimComp){ // 30 - score = 2; + band = 5; msg << "MEDIOCRE" << endl; }else if (dist < TARGET_SCORE_CC_BAND*9*dimComp){ // 45 - score = 1; + band = 6; msg << "POOR..." << endl; }else{ - score = 0; + band = 7; msg << "MISSED COMPLETELY!" << endl; @@ -103,29 +108,36 @@ result.timeAllowed = timeAllowed; result.score = round(TP*10); result.displayText = msg.str(); + result.difficultyLevel = difficulty; + ofColor c; if(result.targetBandHit == 1){ - // yellow red blue - c = ofColor(255,255,0,255); + + c = ofColor(255,255,0,255); // yellow 1 }else if(result.targetBandHit == 2){ - c = ofColor(255,0,0,255); + c = ofColor(255,0,0,255); // red 2 }else if(result.targetBandHit == 3){ - c = ofColor(45,45,255,255); + c = ofColor(45,45,255,255); // blue 3 }else if(result.targetBandHit == 4){ - c = ofColor(0,255,0,255); + c = ofColor(0,255,0,255); // green 4 }else{ - c = ofColor(150,235,200,255); + c = ofColor(0,0,0,255); // black worst } result.colorBand = c; totalScored += score; vector<int> details; - details.push_back(result.realDistanceToTarget); + + details.push_back(result.realDistanceToTarget*1000); details.push_back(result.targetBandHit); details.push_back(result.timeAllowed); details.push_back(result.score); // 10 x throughput + details.push_back(difficulty); + details.push_back(whichInSequence); + details.push_back(initDist*1000); + details.push_back(presetIndex); eventLogger.logEvent(TRAINING_RESULT, details); details.clear(); @@ -142,7 +154,8 @@ float calculateThroughput(int numDims, float endDistance, float startDistance, float time) const{ - + if (startDistance == 0) startDistance = 1; + if (endDistance == 0) endDistance = 1; float ISSR = numDims * log2( startDistance / endDistance); cout << "==========Result======= " << endl; cout << "start: " << startDistance << endl;