#include "control.h" #include #include #include #include #include using namespace std; control::control(void) { x_coord =-1; y_coord =-1; pitch_recog =-1.0; pitch_quality =0.0; } double control::getFuzzyBad(double percentage) { if(percentage < 25) return (percentage/25); else if (percentage < 50) return 1.0 - ((percentage - 25) / 25); else return 0.0; } double control::getFuzzyAvg(double percentage) { if(percentage < 25) return 0.0; else if (percentage < 50) return ((percentage - 25) / 25); else if (percentage < 75) return 1.0 - ((percentage - 50) / 25); else return 0.0; } double control::getFuzzyGreat(double percentage) { if(percentage < 50) return 0.0; else if (percentage < 75) return ((percentage - 50) / 25); else return 1.0 - ((percentage - 75) / 25); } void control::rules() { double pitch_quality_bad = min(getFuzzyBad(x_coord), getFuzzyBad(y_coord)); double pitch_quality_great = min(getFuzzyGreat(x_coord), getFuzzyGreat(y_coord)); double pitch_quality_avg = min(getFuzzyAvg(x_coord), getFuzzyAvg(y_coord)); pitch_quality = calc_quality(pitch_quality_bad,pitch_quality_avg, pitch_quality_great ); pitch_recog = pitch_recog/100.0; //fuzzify //RULE 1 if(pitch_quality >= .75 && pitch_recog >=.75) cout<<"Swing for the fences. In the sweetspot and a fastball."<=.75 && pitch_recog >=.5) //RULE 2 cout<<"Line Drive Swing, good pitch wait for the breaking stuff"<=.75 && pitch_recog >=.25) //RULE 3 cout<<"Put in play, choke up curveball over the plate"<=.5 && pitch_recog >=.75) //RULE 4 cout<<"Line Drive Swing, over the plate fastball"<=.5 && pitch_recog >=.5) //RULE 5 cout<<"Put in play, over the plate slider or fastball"<=.5 && pitch_recog >=.25) //RULE 6 cout<<"Put in play, over the plate unsure pitch recognition"<=.25 && pitch_recog >=.75) //RULE 7 cout<<"Put in play, fastball"<