changeset 22:8124f46eda65

pretty much working. ugly though.
author Robert Tubb <rt300@eecs.qmul.ac.uk>
date Thu, 23 Oct 2014 18:15:46 +0100
parents 5cf2b80909fc
children 055e0c43afe5
files MessageOrganiser.h MessageOrganiser.mm SequenceController.h SequenceController.mm TestController.h TestController.mm TrainingMessageOrganiser.h TrainingMessageOrganiser.mm TrainingScoreManager.h TrainingScoreManager.mm UI code/Buttron.mm UI code/ButtronSlider.h UI code/ButtronSlider.mm UI code/TextPanel.h UI code/TextPanel.mm UI code/UIProperties.h UI code/sliderPanel.h algorithms.h algorithms.mm testApp.mm
diffstat 20 files changed, 459 insertions(+), 145 deletions(-) [+]
line wrap: on
line diff
--- a/MessageOrganiser.h	Wed Oct 22 18:12:12 2014 +0100
+++ b/MessageOrganiser.h	Thu Oct 23 18:15:46 2014 +0100
@@ -87,7 +87,7 @@
     void paramChangeCallback(int mappingID, int value);
     void sendSynthValuesAgain();
     void setAllSlidersToValues(vector<int> values);
-    
+    void setCandidateAndSlidersToRandom();
     // we want to set UI object
     void setUIToParam(int index, int value);
     void mapControlToParam(UIElement* control, int mappingID);
--- a/MessageOrganiser.mm	Wed Oct 22 18:12:12 2014 +0100
+++ b/MessageOrganiser.mm	Thu Oct 23 18:15:46 2014 +0100
@@ -194,7 +194,19 @@
 //    }
 }
 void MessageOrganiser::setSlidersToDefault(){
-    for(int i=1; i < targetSynth.getNumParams(); i++){
+    for(int i=1; i < candidateSynth.getNumParams(); i++){
         setUIToParam(i, 0);
+        
     }
+}
+void MessageOrganiser::setCandidateAndSlidersToRandom(){
+    vector<int> rands;
+    for(int i = 0; i < candidateSynth.getNumParams(); i++){
+        
+        rands.push_back(rand() % 127);
+    }
+    
+    setAllSlidersToValues(rands);
+    candidateSynth.setAllParams(rands);
+    
 }
\ No newline at end of file
--- a/SequenceController.h	Wed Oct 22 18:12:12 2014 +0100
+++ b/SequenceController.h	Thu Oct 23 18:15:46 2014 +0100
@@ -12,16 +12,17 @@
 #include <iostream>
 #include "ofMain.h"
 
-#define MIN_TARGETS_IN_SEQUENCE 3
+#define MIN_TARGETS_IN_SEQUENCE 1
 #define MAX_TARGETS_IN_SEQUENCE 5
-#define MIN_TEMPO   120
-#define MAX_TEMPO   250
-#define NUM_TEMPO_STEPS 16
+#define MIN_TEMPO   60
+#define MAX_TEMPO   120
+#define NUM_TEMPO_STEPS 8
 #define NUM_PRESETS 8
 
+
 class Step{
 public:
-    typedef enum {COUNT_IN, PREVIEW_DISPLAY, PREVIEW_PLAY, MATCHING_INTERACTION, MATCHING_RESULT} stepTypes;
+    typedef enum {COUNT_IN, PREVIEW_PREPARER, PREVIEW_DISPLAYER, MATCHING_PREPARER, MATCHING_INTERACTION, MATCHING_RESULT} stepTypes;
     
     Step();
     
@@ -43,17 +44,20 @@
     int runNumber;
     bool isLastOfSeq;
     bool isLastOfRun;
-    bool playsMetroClick;
+    bool showsCountDown;
+    bool hidesSliders;
     int tempo;
 // preset info
     int presetIndex;
     int numInSequence;
     bool isLastOfAll;
 
-    void setAsPreviewShower();
+    void setAsBlankCounter();
+    void setAsPreviewPreparer();
     void setAsPreviewPlayer();
     void setAsMatchingPreparer();
-    void setAsMatchingReckoner();
+    void setAsMatchingInteraction();
+    void setAsMatchingFeedback();
     
     float getTimeBetweenTicks(){
         return 1000. * (60.0/tempo);
--- a/SequenceController.mm	Wed Oct 22 18:12:12 2014 +0100
+++ b/SequenceController.mm	Thu Oct 23 18:15:46 2014 +0100
@@ -15,13 +15,14 @@
     showsControlSettings = false;
     showsControlGuides = false;
     showsMatchResults = false;
+    hidesSliders = true;
     isPreview = false;
     
     allowsCandidateControl = false;
     playsTarget = false;
     playsCandidate = false;
     
-    playsMetroClick = true;
+    showsCountDown = true;
     
     isLastOfSeq = false;
     isLastOfRun = false;
@@ -32,64 +33,101 @@
     
     tempo = MIN_TEMPO;
 }
-
-void Step::setAsPreviewShower(){
-    type = PREVIEW_DISPLAY;
+void Step::setAsBlankCounter(){
+    type = COUNT_IN;
+    showsTargetIcon = false;
+    showsControlSettings = false;
+    showsControlGuides = false;
+    showsMatchResults = false;
+    hidesSliders = true;
+    isPreview = false;
+    
+    allowsCandidateControl = false;
+    playsTarget = false;
+    playsCandidate = false;
+    showsCountDown = true;
+    
+}
+void Step::setAsPreviewPreparer(){
+    type = PREVIEW_PREPARER;
     showsTargetIcon = true;
-    showsControlSettings = true;
-    showsControlGuides = true;
+    showsControlSettings = false;
+    showsControlGuides = false;
     showsMatchResults = false;
+    hidesSliders = true;
     isPreview = true;
     
     allowsCandidateControl = false;
     playsTarget = true;
     playsCandidate = false;
-    playsMetroClick = false;
+    showsCountDown = true;
 }
+
 void Step::setAsPreviewPlayer(){
-    type = PREVIEW_PLAY;
+    type = PREVIEW_DISPLAYER;
     showsTargetIcon = true;
     showsControlSettings = true;
-    showsControlGuides = true;
+    showsControlGuides = false;
     showsMatchResults = false;
+    hidesSliders = false;
+    
     isPreview = true;
     
     allowsCandidateControl = false;
     playsTarget = true;
     playsCandidate = false;
     
-    playsMetroClick = false;
+    showsCountDown = false;
 }
+
 void Step::setAsMatchingPreparer(){
+    // just a count down
+    type = MATCHING_PREPARER;
+    showsTargetIcon = true;
+    showsControlSettings = false;
+    showsControlGuides = false;
+    showsMatchResults = false;
+    hidesSliders = true;
+    
+    isPreview = false;
+    
+    allowsCandidateControl = false;
+    playsTarget = true;
+    playsCandidate = false;
+    
+    showsCountDown = true;
+}
+void Step::setAsMatchingInteraction(){
     type = MATCHING_INTERACTION;
     showsTargetIcon = true;
     showsControlSettings = false;
-    showsControlGuides = true;
+    showsControlGuides = false;
     showsMatchResults = false;
+    hidesSliders = false;
     isPreview = false;
     
     allowsCandidateControl = true;
     playsTarget = false;
-    playsCandidate = false;
+    playsCandidate = false; // ??
     
-    playsMetroClick = false;
+    showsCountDown = false;
 }
-void Step::setAsMatchingReckoner(){
-    type = MATCHING_RESULT;
-    showsTargetIcon = true;
+void Step::setAsMatchingFeedback(){
+    type = MATCHING_INTERACTION;
+    showsTargetIcon = false;
     showsControlSettings = false;
-    showsControlGuides = true;
-    showsMatchResults = true; // shows how far off you were?
+    showsControlGuides = false;
+    showsMatchResults = true;
+    hidesSliders = true;
     isPreview = false;
     
     allowsCandidateControl = false;
     playsTarget = false;
-    playsCandidate = true;
+    playsCandidate = true; // ??
     
-    playsMetroClick = false;
+    showsCountDown = false;
 }
 
-
 //=================================================================
 //=================================================================
 //=================================================================
@@ -149,22 +187,32 @@
 void SequenceController::generateARun(int run, int numInSequence){
     float curTempo = MIN_TEMPO;
     int seqNo = 0;
-    
+    Step nextStep;
     for(int tempoLevel = 0; tempoLevel < NUM_TEMPO_STEPS; tempoLevel++){
         
-        vector<int> stepPreset;
+        
+        
+        // first we have a preparation count in
+        nextStep.presetIndex = -1; // minus one means "blank"
+        nextStep.runNumber = run;
+        nextStep.seqNumber = seqNo;
+        nextStep.numInSequence = 0;
+        nextStep.tempo = curTempo;
+        nextStep.setAsBlankCounter();
+        
+        // generate a sequence
+        vector<int> stepPresetIndices;
         
         // get some random ints
         for(int n=0; n < numInSequence; n++){
-            int nextPreset = getRandomButNot(NUM_PRESETS,stepPreset);
-            stepPreset.push_back(nextPreset);
+            int nextPreset = getRandomButNot(NUM_PRESETS,stepPresetIndices);
+            stepPresetIndices.push_back(nextPreset);
             cout << nextPreset << ",";
         }
-        // put preview
-        Step nextStep;
-        
-        int n = 0;
-        for(auto si = stepPreset.begin(); si < stepPreset.end(); si++){
+
+        // make preview sequence
+        int n = 1;
+        for(auto si = stepPresetIndices.begin(); si < stepPresetIndices.end(); si++){
             // put loader
             
             nextStep.presetIndex = *si;
@@ -172,7 +220,7 @@
             nextStep.seqNumber = seqNo;
             nextStep.numInSequence = n;
             nextStep.tempo = curTempo;
-            nextStep.setAsPreviewShower();
+            nextStep.setAsPreviewPreparer();
             steps.push_back(nextStep);
             
             // put player
@@ -181,21 +229,27 @@
             steps.push_back(nextStep);
             n++;
         }
-        // last one in sequence allows control ?
-        steps.back().allowsCandidateControl = true;
+
+        // now we waqnt a matching preparation count in
+//        nextStep.setAsBlankCounter();
+//        steps.push_back(nextStep);
+        
         // put in matching sequence
         n = 0;
-        for(auto si = stepPreset.begin(); si < stepPreset.end(); si++){
+        for(auto si = stepPresetIndices.begin(); si < stepPresetIndices.end(); si++){
             // put loader
             
             nextStep.presetIndex = *si;
             nextStep.numInSequence = n;
+
             nextStep.setAsMatchingPreparer();
             steps.push_back(nextStep);
             
-            // put player
+            nextStep.setAsMatchingInteraction();
+            steps.push_back(nextStep);
+            n++;
             
-            nextStep.setAsMatchingReckoner();
+            nextStep.setAsMatchingFeedback();
             steps.push_back(nextStep);
             n++;
         }
@@ -206,6 +260,8 @@
         cout << endl;
         
     }
+    nextStep.setAsBlankCounter();
+    steps.push_back(nextStep);
     
 }
 
--- a/TestController.h	Wed Oct 22 18:12:12 2014 +0100
+++ b/TestController.h	Thu Oct 23 18:15:46 2014 +0100
@@ -18,54 +18,11 @@
 #include "boost/bind.hpp"
 #include "boost/function.hpp"
 #include "timeController.h"
+#include "algorithms.h"
 #include <functional>
 #include <algorithm>    // std::transform
 
 //-------------------------------------------------------------
-//-------------------------------------------------------------
-template <class T>
-class randomiseCCVal : public unary_function<T, T>{
-public:
-    T operator()(T a){
-        return ofRandom(0,127);
-        
-    };
-};
-template <class T>
-class randomiseCCValIf : public binary_function<T, bool, T>{
-public:
-    T operator()(T a, bool doit ){
-        if (doit)
-            return ofRandom(0,127);
-        return a;
-        
-    };
-};
-template <class T>
-class printThing : public unary_function<T, void>{
-public:
-    void operator()(T a){
-        cout << a << endl;
-        
-    };
-};
-
-template <class T>
-class difference : public binary_function<T, T, T>{
-public:
-    T operator()(T a, T b ){
-        return abs(a - b);
-    };
-};
-template <class T>
-class squared : public unary_function<T, T>{
-public:
-    T operator()(T a ){
-        return a*a;
-    };
-};
-
-//-------------------------------------------------------------
 
 struct TestResult{
     float realDistanceToTarget;
--- a/TestController.mm	Wed Oct 22 18:12:12 2014 +0100
+++ b/TestController.mm	Thu Oct 23 18:15:46 2014 +0100
@@ -11,26 +11,6 @@
 const int TestController::totalNumTests = 80;
 
 
-template <typename T>
-vector<T> makeVector(T a1, T a2,T a3,T a4,T a5,T a6, T a7, T a8){
-    
-    vector<T> vec;
-    vec.push_back(a1);
-    vec.push_back(a2);
-    vec.push_back(a3);
-    vec.push_back(a4);
-    vec.push_back(a5);
-    vec.push_back(a6);
-    vec.push_back(a7);
-    vec.push_back(a8);
-    return vec;
-}
-
-void randomise(int& n){
-    n = ofRandom(0,127);
-    
-}
-
 vector<vector <bool> > makeCombinations(){
     // make all unordered pairs
     int N = TOTAL_NUM_PARAMS;
@@ -56,6 +36,7 @@
     }
     return table;
 }
+
 //----------------------------------------------------------------------------------------
 
 void TestController::generate2DRandomTests(){
--- a/TrainingMessageOrganiser.h	Wed Oct 22 18:12:12 2014 +0100
+++ b/TrainingMessageOrganiser.h	Thu Oct 23 18:15:46 2014 +0100
@@ -14,19 +14,22 @@
 #include "SequenceController.h"
 #include "globalVariables.h"
 #include "IconPanel.h"
-
+#include "TextPanel.h"
+#include "TrainingScoreManager.h"
 extern ExplorePresetManager expPresetManager;
 
 class TrainingMessageOrganiser : public MessageOrganiser {
 public:
     int numParamsToUse;
     void init( PDSynthWrapper& cs, PDSynthWrapper& ts);
-    
+    void setMiddlePanel(TextPanel* tp);
     void setupDefaultMapping();
     vector<int> getMappingIDsFromSynths();
     void displayInstructions(Step s);
     void onNextTick(int tickNumber);
-
+    
+    void showMyPanels();
+    
     //-----------------------------------------------------------------------
 protected:
     void showUserHowTheyDid();
@@ -39,9 +42,12 @@
         }
         cout << endl;
     }
+    ofColor interactableColor;
+    ofColor nonInteractableColor;
+    int downCounter;
     //-----------------------------------------------------------------------------
-    
+    TextPanel* middlePanel;
     SequenceController sequenceController;
-
+    TrainingScoreManager trainingScoreManager;
 };
 #endif /* defined(__riftathon__TrainingMessageOrganiser__) */
--- a/TrainingMessageOrganiser.mm	Wed Oct 22 18:12:12 2014 +0100
+++ b/TrainingMessageOrganiser.mm	Thu Oct 23 18:15:46 2014 +0100
@@ -20,6 +20,10 @@
     
 }
 
+void TrainingMessageOrganiser::setMiddlePanel(TextPanel* tp){
+    middlePanel = tp;
+}
+
 void TrainingMessageOrganiser::setupDefaultMapping(){
     vector<int> mappingIDsForChangeableParams = getMappingIDsFromSynths();
     
@@ -49,37 +53,59 @@
     return mids;
 }
 
+void TrainingMessageOrganiser::showMyPanels(){
+    presetIconPanel->show();
+    instructionPanel->show();
+    bottomPanel->show();
+    panel->hide();
+    middlePanel->show();
+}
 
 //-----------------------------------------------------------------------
 void TrainingMessageOrganiser::displayInstructions(Step s){
     
     
     if (s.type == Step::COUNT_IN){
-        instructionPanel->setText("GET READY");
+        instructionPanel->setText("COUNT_IN" + ofToString(downCounter));
+        middlePanel->setText(ofToString(downCounter));
     }
-    if (s.type == Step::PREVIEW_DISPLAY){
-        instructionPanel->setText("MEMORISE");
+    if (s.type == Step::PREVIEW_PREPARER){
+        instructionPanel->setText("PREVIEW_PREPARER");
         panel->setColor(ofColor(0,0,0));
     }
-    if (s.type == Step::PREVIEW_PLAY){
-        instructionPanel->setText("MEMORISE");
+    
+    if (s.type == Step::PREVIEW_DISPLAYER){
+        instructionPanel->setText("PREVIEW_DISPLAYER");
         panel->setColor(ofColor(0,0,0));
     }
+    if (s.type == Step::MATCHING_PREPARER){
+        instructionPanel->setText("MATCHING_PREPARER");
+        middlePanel->setText(ofToString(downCounter));
+        panel->setColor(ofColor(250,0,0));
+    }
     if (s.type == Step::MATCHING_INTERACTION){
-        instructionPanel->setText("MATCH:");
-        panel->setColor(ofColor(100,0,0));
+        instructionPanel->setText("MATCHING_INTERACTION!!!!");
+        panel->setColor(ofColor(250,0,0));
     }
     if (s.type == Step::MATCHING_RESULT){
         instructionPanel->setText("RESULT");
-        panel->setColor(ofColor(0,100,0));
+        panel->setColor(ofColor(0,0,0));
     }
 }
 //-----------------------------------------------------------------------
 void TrainingMessageOrganiser::onNextTick(int tickNumber){
+    static int showingCountdown = false;
     cout << "TICK " << tickNumber << endl;
+    downCounter = 4 - tickNumber % 4;
+    
+    if (showingCountdown){
+        middlePanel->setColor(ofColor::white);
+        middlePanel->setText(ofToString(downCounter));
+    }
     
     // only first beat in bar is active one
     if ( tickNumber % 4  != 0){
+        
         return;
     }
     // load next target preset
@@ -91,29 +117,51 @@
         // do finished run stuff, show summary
         candidateSynth.stopMetronome();
         cout << "FINISHED BLOCK" << endl;
+        middlePanel->setColor(ofColor::white);
+        middlePanel->setText("FINISHED BLOCK");
+        return;
     }
     if(newStep.isLastOfRun){
         // do finished run stuff, show summary
         candidateSynth.stopMetronome();
         cout << "FINISHED RUN" << endl;
+        middlePanel->setColor(ofColor::white);
+        middlePanel->setText("FINISHED RUN");
+        middlePanel->show();
+        return;
     }
+
+    candidateSynth.setMetroTime(newStep.getTimeBetweenTicks());
     
-    float t = newStep.getTimeBetweenTicks();
-    candidateSynth.setMetroTime(t);
-    
-    if(newStep.type == Step::COUNT_IN){
+    if(newStep.showsCountDown){
         // count in
-        return;
+        showingCountdown = true;
+        middlePanel->show();
+    }else{
+        showingCountdown = false;
     }
     
     Preset * currentTargetPreset;
     
     if(newStep.presetIndex >= 0 && newStep.presetIndex <= 8){
         currentTargetPreset =  expPresetManager.getPresetAtIndex(newStep.presetIndex);
+    }else{
+        assert(newStep.type == Step::COUNT_IN);
+        // nothing happens here
+        return;
     }
 
-    vector<int> newValues = currentTargetPreset->getValues();
-    debugVals(newValues);
+    vector<int> newTargetValues = currentTargetPreset->getValues();
+    debugVals(newTargetValues);
+    
+    if(newStep.hidesSliders){
+        panel->hide();
+        middlePanel->setBackground(ofColor(255,0,0));
+        middlePanel->show();
+    }else{
+        panel->show();
+        middlePanel->hide();
+    }
     
     if(newStep.showsTargetIcon){
         bool showTick = true;
@@ -124,6 +172,7 @@
     }
     
     if(newStep.allowsCandidateControl){
+        setCandidateAndSlidersToRandom();
         panel->setActive(true);
     }else{
         panel->setActive(false);
@@ -131,20 +180,20 @@
     
     if(newStep.showsControlSettings){
         // actually alters the slider values
-        targetSynth.setAllParams(newValues);
-        setAllSlidersToValues(newValues);
+        targetSynth.setAllParams(newTargetValues);
+        setAllSlidersToValues(newTargetValues);
         
     }else{
-        //setSlidersToDefault();
+        
         
     }
     
+    panel->setHintValues(newTargetValues);
 
     
     if(newStep.showsControlGuides){
         // shows visual target lines on sliders (or target hand in VR)
         
-        panel->setHintValues(newValues);
         panel->showHint(true);
     }else{
         panel->showHint(false);
@@ -153,10 +202,25 @@
     
     if(newStep.showsMatchResults){
         // do something
+        //newStep->calculateResults();
+        TrainingTestResult result =
+            trainingScoreManager.getScoreForAnswer(candidateSynth.getAllParamValues(),
+                                                   newTargetValues,
+                                                   newStep.getTimeBetweenTicks());
+        
+        
+        //middlePanel->setLabel(result.displayText);
+        middlePanel->setColor(result.colorBand);
+        middlePanel->setText(result.displayText);
+        panel->setHintColor(result.colorBand);
+        panel->showHint(true);
+        middlePanel->show();
+    }else{
+        middlePanel->setText("");
     }
     
     if(newStep.playsTarget){
-        targetSynth.setAllParams(newValues);
+        targetSynth.setAllParams(newTargetValues);
         targetSynth.trigger();
     }
     if(newStep.playsCandidate){
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TrainingScoreManager.h	Thu Oct 23 18:15:46 2014 +0100
@@ -0,0 +1,136 @@
+//
+//  TrainingScoreManager.h
+//  riftathon
+//
+//  Created by Robert Tubb on 23/10/2014.
+//
+//
+
+#ifndef __riftathon__TrainingScoreManager__
+#define __riftathon__TrainingScoreManager__
+
+#include <iostream>
+#include "ofMain.h"
+#include "SequenceController.h"
+#include "algorithms.h"
+#include "globalVariables.h"
+//-------------------------------------------------------------
+
+struct TrainingTestResult{
+    float realDistanceToTarget;
+    int targetBandHit; // eg bullseye = 0 edge = 7
+    float timeAllowed;
+    int score;
+    ofColor colorBand;
+    string displayText;
+};
+
+class TrainingScoreManager{
+    
+    // equiv of score bit of testController
+public:
+    
+    TrainingTestResult getScoreForAnswer(vector<int> targetParams, vector<int> answer, int timeAllowed) const {
+        TrainingTestResult result;
+        stringstream msg;
+        int score = 0;
+        // work out euc distance from actual point
+        //for_each(answer.begin(),answer.end(),printThing<int>());
+        //for_each(targetParams.begin(),targetParams.end(),printThing<int>());
+        float dist = euclideanDistance(targetParams, answer);
+        auto dimComp = sqrt(6.0);
+        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;
+            
+            
+        }
+        msg << "Distance from target: " << dist << endl;
+        msg << "Basic Score: " << score << endl;
+        msg << "-----" << endl;
+        msg << "Time allowed: " << timeAllowed/1000.0 << endl;
+
+        msg << "-----" << endl;
+
+        result.realDistanceToTarget = dist;
+        result.targetBandHit = band; // eg bullseye = 0 edge = 7
+        result.timeAllowed = timeAllowed;
+        result.score = score;
+        result.displayText = msg.str();
+        
+        ofColor c;
+        if(result.targetBandHit == 1){
+            // yellow red blue
+            c = ofColor(255,255,0,255);
+        }else if(result.targetBandHit == 2){
+            c = ofColor(255,0,0,255);
+        }else if(result.targetBandHit == 3){
+            c = ofColor(45,45,255,255);
+        }else if(result.targetBandHit == 4){
+            c = ofColor(0,255,0,255);
+        }else{
+            c = ofColor(150,235,200,255);
+        }
+        result.colorBand = c;
+
+        
+        return result;
+    }
+private:
+    
+    float euclideanDistance(vector<int> v1, vector<int> v2) const{
+        if (v1.size() != v2.size()){
+            cout << "ERROR ERROR: vectors must be same length for Mr Euclid";
+            return 0.;
+        }
+        vector<float> diff;
+        
+        std::transform(v1.begin(), v1.end(), v2.begin(), v1.begin(), difference<float>());
+        // sqr diff
+        
+        std::transform(v1.begin(), v1.end(), v1.begin(),squared<float>());
+        float ans = std::accumulate(v1.begin(),v1.end(),0.0);
+        
+        return sqrt(ans);
+        
+    };
+    
+};
+#endif /* defined(__riftathon__TrainingScoreManager__) */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TrainingScoreManager.mm	Thu Oct 23 18:15:46 2014 +0100
@@ -0,0 +1,9 @@
+//
+//  TrainingScoreManager.cpp
+//  riftathon
+//
+//  Created by Robert Tubb on 23/10/2014.
+//
+//
+
+#include "TrainingScoreManager.h"
--- a/UI code/Buttron.mm	Wed Oct 22 18:12:12 2014 +0100
+++ b/UI code/Buttron.mm	Thu Oct 23 18:15:46 2014 +0100
@@ -114,6 +114,9 @@
         fg = foregroundLo;
         bg = backgroundLo;
     }
+    if(inactive){
+        ofSetColor(fgInactive);
+    }
     ofSetColor(fg);
     
     float cornerSize = thickness + radius;
--- a/UI code/ButtronSlider.h	Wed Oct 22 18:12:12 2014 +0100
+++ b/UI code/ButtronSlider.h	Thu Oct 23 18:15:46 2014 +0100
@@ -47,6 +47,10 @@
     void setHintColor(ofColor c){
         hintColor = c;
     };
+    void setColor(ofColor c){
+        foregroundHi = c;
+        foregroundLo = c;
+    }
     void showHint(bool tf){
         hintShowing = tf;
     };
--- a/UI code/ButtronSlider.mm	Wed Oct 22 18:12:12 2014 +0100
+++ b/UI code/ButtronSlider.mm	Thu Oct 23 18:15:46 2014 +0100
@@ -77,9 +77,9 @@
 void ButtronSlider::drawHintIndicator(){
 
     ofSetColor(hintColor);
-    float hthick = 3;
+    float hthick = 6;
     double loc = y + hthick +  (1 - hintValue)*(height-3*hthick);
-    ofRect(x+thickness,loc, width-2*thickness,hthick);
+    ofRect(x-thickness,loc, width+2*thickness,hthick);
 
 }
 
--- a/UI code/TextPanel.h	Wed Oct 22 18:12:12 2014 +0100
+++ b/UI code/TextPanel.h	Thu Oct 23 18:15:46 2014 +0100
@@ -28,6 +28,11 @@
     ofColor foregroundLo;
     ofColor backgroundLo;
     
+    void setBackground(ofColor c){
+        backgroundHi = c;
+        backgroundLo = c;
+        
+    }
     bool handleMyTouch(int x, int y, touchType ttype, int touchID){
         return false;
     }
--- a/UI code/TextPanel.mm	Wed Oct 22 18:12:12 2014 +0100
+++ b/UI code/TextPanel.mm	Thu Oct 23 18:15:46 2014 +0100
@@ -34,9 +34,9 @@
     if(fontSize == SMALLFONT){
         smallFont.drawString(theText, x, y + 8);
     }else if(fontSize == LARGEFONT){
-        bigFont.drawString(theText, x, y + 8);
+        bigFont.drawString(theText, x, y + 16);
     }else{
-        verdana16.drawString(theText, x, y + 8);
+        verdana16.drawString(theText, x, y + 12);
     }
     
     //ofRect(x,y,width,height);
--- a/UI code/UIProperties.h	Wed Oct 22 18:12:12 2014 +0100
+++ b/UI code/UIProperties.h	Thu Oct 23 18:15:46 2014 +0100
@@ -46,7 +46,7 @@
         verdana16.setLetterSpacing(1.037);
         
         bigFont.loadFont("verdana.ttf", 28, true, true);
-        bigFont.setLineHeight(22.0f);
+        bigFont.setLineHeight(30.0f);
         bigFont.setLetterSpacing(1.037);
         
         smallFont.loadFont("verdana.ttf", 10, true, true);
--- a/UI code/sliderPanel.h	Wed Oct 22 18:12:12 2014 +0100
+++ b/UI code/sliderPanel.h	Thu Oct 23 18:15:46 2014 +0100
@@ -57,6 +57,12 @@
             (*UIitr)->setHintColor(c);
         }
     }
+    void setSliderColors(ofColor c){
+        for(auto UIitr = subElements.begin(); UIitr < subElements.end(); UIitr++){
+            ButtronSlider* thisSlider = (ButtronSlider *)(*UIitr);
+            thisSlider->setColor(c);
+        }
+    }
     //------------------------
     void flash(){
         // turn hilight on and off
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/algorithms.h	Thu Oct 23 18:15:46 2014 +0100
@@ -0,0 +1,70 @@
+#pragma once
+
+#include "ofMain.h"
+#include <functional>
+
+
+
+template <typename T>
+vector<T> makeVector(T a1, T a2,T a3,T a4,T a5,T a6, T a7, T a8){
+    
+    vector<T> vec;
+    vec.push_back(a1);
+    vec.push_back(a2);
+    vec.push_back(a3);
+    vec.push_back(a4);
+    vec.push_back(a5);
+    vec.push_back(a6);
+    vec.push_back(a7);
+    vec.push_back(a8);
+    return vec;
+}
+
+void randomise(int& n){
+    n = ofRandom(0,127);
+    
+}
+
+//-------------------------------------------------------------
+//-------------------------------------------------------------
+template <class T>
+class randomiseCCVal : public unary_function<T, T>{
+public:
+    T operator()(T a){
+        return ofRandom(0,127);
+        
+    };
+};
+template <class T>
+class randomiseCCValIf : public binary_function<T, bool, T>{
+public:
+    T operator()(T a, bool doit ){
+        if (doit)
+            return ofRandom(0,127);
+        return a;
+        
+    };
+};
+template <class T>
+class printThing : public unary_function<T, void>{
+public:
+    void operator()(T a){
+        cout << a << endl;
+        
+    };
+};
+
+template <class T>
+class difference : public binary_function<T, T, T>{
+public:
+    T operator()(T a, T b ){
+        return abs(a - b);
+    };
+};
+template <class T>
+class squared : public unary_function<T, T>{
+public:
+    T operator()(T a ){
+        return a*a;
+    };
+};
--- a/algorithms.mm	Wed Oct 22 18:12:12 2014 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,5 +0,0 @@
-#pragma once
-
-#include "ofMain.h"
-#include <functional>
-
--- a/testApp.mm	Wed Oct 22 18:12:12 2014 +0100
+++ b/testApp.mm	Thu Oct 23 18:15:46 2014 +0100
@@ -156,6 +156,12 @@
     trainingMessageOrganiser.setInstructionPanel(instructionPanel);
     instructionPanel->hide();
     
+    TextPanel * middlePanel = new TextPanel("Middle panel", 200, 200, 400,400,(*props));
+    middlePanel->setFontSize(LARGEFONT);
+    UIElements.push_back(middlePanel);
+    trainingMessageOrganiser.setMiddlePanel(middlePanel);
+    middlePanel->show();
+    
 }
 //--------------------------------------------------------------
 // gui for the old style tweakathlon  stage