Download presentation
Presentation is loading. Please wait.
Published byLaurel Leonard Modified over 9 years ago
1
1 Fuzzy Logic Artificial Intelligence for Games Scott Goodwin School of Computer Science See Buckland, Chapter 10
2
2 Crisp Words 1. Cut two slices of bread a half inch thick 2. Turn the heat on the griddle to 400 degrees 3. Grill the slices on one side for 2 minutes 4. Turn the slices over and add a 1 ounze of cheese 5. Replace and grill for 30 seconds 6. Remove, sprinkle on a ¼ gram of black pepper, and eat. 7. When the enemy has come within 80 feet, if you have at least 10 rockets, fire the rocket launcher.
3
3 Fuzzy Words 1. Cut two slices of bread medium thick 2. Turn the heat on the griddle to high 3. Grill the slices on one side until golden brown 4. Turn the slices over and add a generous helping of cheese 5. Replace and grill until the top of the cheese is slightly brown 6. Remove, sprinkle on a small amount of black pepper, and eat. 7. When the enemy has come within medium range, if ammo is plentiful, fire the rocket launcher.
4
4 Crisp Sets Crisp sets are the kind of sets you learn about in math class A set contains elements Elements are either in a set or not in the set (e.g., set of even integers) Degree of membership is 0 or 1 Operations are defined on sets (intersection, union, complement
5
5 Fuzzy Sets IQ 85 is kind of dumb but almost average How can we make crisp sets fuzzy? How do we blur (fuzzify) the boundaries between sets? DumbAverage Clever DumbAverageClever Fuzzify
6
6 Fuzzification We can define partial membership in a set using a function The function could have one of many different shapes Gradual or abrupt transition Degree of membership
7
7 Degree of Membership (DOM) Let’s suppose Brian has an IQ of 115 DOM clever (115) = 0.75 DOM average (115) = 0.25 DOM dumb (115) = 0
8
8 Fuzzy AND Operator Fuzzy AND is the intersection of two (or more) fuzzy sets which is itself a fuzzy set DOM average ^ clever (x) = min{DOM average (x), DOM clever (x)} DOM average ^ clever (115) = min{DOM average (115), DOM clever (115)} = min{0.25, 0.75} = 0.25
9
9 Fuzzy OR Operator Fuzzy OR is the union of two (or more) fuzzy sets which is itself a fuzzy set DOM average V clever (x) = max{DOM average (x), DOM clever (x)} DOM average V clever (115) = max {DOM average (115), DOM clever (115)} = max {0.25, 0.75} = 0.75
10
10 Fuzzy NOT Operator Fuzzy NOT is complement of a fuzzy set which is itself a fuzzy set DOM ¬clever (x) = 1 - DOM clever (x) DOM ¬clever (115) = 1 - DOM clever (115)} = 1 - 0.75 = 0.25
11
11 Fuzzy Hedges Unary operators that modify the membership function of a fuzzy set DOM very(clever) (x) = DOM clever (x) 2 DOM very(clever) (115) = DOM clever (115) 2 = 0.75 2 = 0.5625 DOM fairly(clever) (x) = DOM clever (x) 0.5 DOM fairly(clever) (115) = DOM clever (115) 0.5 = 0.75 0.5 = 0.866
12
12 Fuzzy Identity Laws DeMorgan’s Law Associativity Commutativity Distributivity
13
13 Fuzzy Linguistic Variables A fuzzy linguistic variable (FLV) is a composition of one or more fuzzy sets to represent a domain or concept qualitatively Dumb, Average, Clever are members of the fuzzy linguistic variable IQ IQ = {Dumb, Average, Clever} Speed = {Slow, Medium, Fast} Allegiance = {Friend, Neutral, Foe} Target Heading = {Far left, Left, Center, Right, Far right}
14
14 FLV Target Heading The membership functions of the member sets can have different shapes The collection of shapes (membership functions) that comprise the FLV are called a fuzzy manifold or fuzzy surface
15
15 Fuzzy Rules IF antecedent THEN consequent The DOM of the antecedent defines the degree to which the consequent fires The consequents that fire are combined and defuzzified to give a crisp result
16
16 Designing FLVs for Weapon Selection Suppose the desirability of selecting a weapon from inventory depends on the distance to target and the amount of ammo Each weapon class owns an instance of a Fuzzy Module which contains FLVs represent DistanceToTarget and AmmoStatus (antecedents) FLVs represent DistanceToTarget and AmmoStatus (antecedents) FLV representing Desirability (consequent) FLV representing Desirability (consequent) Fuzzy rules relating antecedents to the consequent Fuzzy rules relating antecedents to the consequent FLVs DistanceToTarget and Desirability are the same for each weapon type FLV AmmoStatus and the Fuzzy rules depend on the weapon type
17
17 Designing FLVs Guidelines: The sum of the DOMs of the fuzzy sets at each point in an FLV should sum to 1. (This ensures smooth transition between values over the FLV’s fuzzy manifold.) The sum of the DOMs of the fuzzy sets at each point in an FLV should sum to 1. (This ensures smooth transition between values over the FLV’s fuzzy manifold.) A vertical line drawn at any point in the FLV should intersect no more than two fuzzy sets A vertical line drawn at any point in the FLV should intersect no more than two fuzzy sets The examples below violate one of these rules
18
18 Designing the Desirability FLV Desirability scores range from 0 to 100 FLV contains three fuzzy sets Undesirable: Left-shouldered fuzzy set Undesirable: Left-shouldered fuzzy set Desirable: Triangular fuzzy set Desirable: Triangular fuzzy set VeryDesirable: Right-shouldered fuzzy set VeryDesirable: Right-shouldered fuzzy set
19
19 Designing the DistanceToTarget FLV The distance scale is in pixels and assumes a RavenBot is about 10 pixels wide
20
20 Designing the AmmoStatus FLV Depends on weapon type, say rocket launcher which fires 2 rockets per second So 10 rockets is Okay, 30 is Loads, etc
21
21 Designing the Fuzzy Rules for Weapon Selection Need a rule for each combination of the antecedents DistanceToTarget (3) x AmmoStatus (3) = 9 combinations For the rocket launcher, it is best at medium distance. At close range, you may get caught in the blast radius. At long range, the target can easily dodge slow rockets.
22
22 Fuzzy Inference We pass the system the input values for the antecedents and apply the above steps. Let’s run through an example with the target at distance=200 and ammo=8
23
23 Rule1: IF Target_Far AND Ammo_Loads THEN Desirable DOM far (200)=0.33 DOM loads (8)=0 AND: min is 0 Conclusion: Desirable = 0
24
24 Rule 2: IF Target_Far AND Ammo_Okay THEN Undesirable DOM far (200)=0.33 DOM okay (8)=0.78 AND: min is 0.33 Conclusion: Undesirable = 0.33
25
25 Rule 3: IF Target_Far AND Ammo_Low THEN Undesirable DOM far (200)=0.33 DOM low (8)=0.2 AND: min is 0.2 Conclusion: Undesirable = 0.2
26
26 Fuzzy Associative Matrix VeryDesirable fired once with confidence 0.67 Desirable fired once with confidence 0.2 Undesirable fired twice with confidences 0.2 and 0.33 How can we handle multiple confidences? Sum (with max=1) or OR the results (take the max) The results for the 9 rules given distance=200 and ammo=8 are summarized in the fuzzy associative matrix The shaded cells highlight rules that fired.
27
27 Clip the consequent The confidence of each consequent is then used to clip the membership functions
28
28 Combine the conclusions The result of combining the conclusions is a composite fuzzy set Next, we need to determine a final crisp value
29
29 Defuzzification Defuzzification determines a crisp value from the inferred composite fuzzy set There are many defuzzification techniques Three of the most common are Mean of Maximum (MOM) Mean of Maximum (MOM) Centroid Centroid Average of Maxima (MaxAv) Average of Maxima (MaxAv)
30
30 Mean of Maximum The maximum confidence value was 0.67 It occurs between 66 and 100. The mean is 83. This is the crisp value of desirability Doesn’t take into account the grayed out sets
31
31 Centroid Most accurate and most difficult to calculate Essentially, find the balance point of the fuzzy manifold Take s samples, sum the contribution of the DOM at each point and divide by the sum of the DOMs
32
32 Centroid Calculation
33
33 Average of Maxima Maximum or representative value is when DOM in the fuzzy set is 1 For triangular fuzzy set, at the peak For trapizoidal or shouldered, average of the endpoints of the plateau Result is close to the more accurate but costlier Centroid
34
34 Raven Fuzzy System
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.