Dustin Stevens-Baier
Comp 569
Assignment #6
When setting up this fuzzy system I decided to go with three different componenets. X coordinate, Y coordinate, and pitch recognition. Basically the system would take a percentage of the x coordinate being good enough to swing at, the y coordinate being good enough and the pitch recognition likelihood. This being wether or not you are able to distinguish the type of pitch. The x and y coordinates would be used to determine the pitch quality and this value along with the pitch recognition value to deteremine what rule is triggered.

I used a pretty simple and straightfoward three options and triangle distribution this seemed to be pretty common in most of the examples I read. Fuzzy logic was created to deal with the concept of partial truths. One of the benefits or detrements depending on who you talk to is the ability to be in more than one state at a time, for example if you where 70% sure of the pitch recognition you would have a bad pitch recognition of 0, an average pitch recognition .1 and a great pitch recognition of .9 This sum will always be 1.0. With each corresponding part having a value ranging from 0 all the way off to 1.0 all the way on.
Fuzzy logic can be used for situations in video games like attacking and fleeing at the same time and to what degree they are doing both. then depending on what the rules are we use this info to have output.
RULES:
1) If pitch quality is great and pitch recognition is great then recommend swing for fences.
2) If pitch quality is great and pitch recognition is average then recommend line drive swing.
3) If pitch quality is great and pitch recognition is bad then recommend putting it in play.
4) If pitch quality is average and pitch recognition is great then recommend line drive swing.
5) If pitch quality is average and pitch recognition is average then recommend putting it in play.
6) If pitch quality is average and pitch recognition is bad then recommend putting it in play.
7) If pitch quality is bad and pitch recognition is great then recommend putting it in play.
8) Otherwise lay off the pitch
Examples: Here are some sample inputs and the related ouput values.
Enter x coordinate percentage
80
Enter y coordinate percentage
80
Enter pitch guess
80
Advice:
Line Drive Swing, over the plate fastball
pitch_quality: 0.64 pitch_recog: 0.8
Enter x coordinate percentage
60
Enter y coordinate percentage
80
Enter pitch guess
80
Advice:
Lay OFF the pitch
pitch_quality: 0.16 pitch_recog: 0.8
Enter x coordinate percentage
40
Enter y coordinate percentage
80
Enter pitch guess
80
Advice:
Lay OFF the pitch
pitch_quality: 0 pitch_recog: 0.8
Enter x coordinate percentage
60
Enter y coordinate percentage
90
Enter pitch guess
80
Advice:
Lay OFF the pitch
pitch_quality: 0.16 pitch_recog: 0.8
Enter x coordinate percentage
60
Enter y coordinate percentage
100
Enter pitch guess
80
Advice:
Lay OFF the pitch
pitch_quality: 0 pitch_recog: 0.8
Enter x coordinate percentage
75
Enter y coordinate percentage
75
Enter pitch guess
80
Advice:
Swing for the fences. In the sweetspot and a fastball.
pitch_quality: 1 pitch_recog: 0.8
Conclusions:
Once all the sample data had been gathered I relealized that there where two pretty obvious improvement areas. The first was the simplified triangle where probablly not a good representation of the fuzzy areas. For one pitch quality was determined by this weighted standard for the triangles and it doesn't really fit with the real world model. For instance a picth at 75 % great x coord and 75 % great y coordinate winds up with a pitch quality of 1.0 fully on. However, if we increase this value to 80% we wind up with .64 great pitch quality. This intuitively doesn't make sense, how can we havea a better pitch both in the y and x areas but wind up with a worse pitch quality. This means that the peak of the final fuzzy area should come at the highest percent. Something like this might be better.

The second area for improvement was the weird rise and falls although not as steep as after 75% there were rise and falls after the peeks at 25% and 50% this again doesn't really model teh real life example very well. As you get a better pitch to hit the value should always steadily rise.
Also learned that it is a little tricky to think in perecentages and then shift to values between 0 and 1. for instance if we take 65% x value we get roughly .4 average pitch quality and .6 great pitch quality. Then you use these values to get the overall pitch quality and then you combine with pitch recognition to deteremine which rule is triggered.
Code: Pretty simple code example given that the straight foward triangle example was used. An adjustment to the getFuzzyGreat function would have to be made for the above change. The function would look like this maxing out at 100.
double control::getFuzzyGreat(double percentage)
{
if(percentage < 50)
return 0.0;
else
return 1.0 - ((percentage -100 ) / 100);
}
References:
Class notes
AI Game Engine Programming Brian Schwab
http://en.wikipedia.org/wiki/Fuzzy_system