1 Fuzzy Logic Artificial Intelligence for Games Scott Goodwin School of Computer Science See Buckland, Chapter 10.

Slides:



Advertisements
Similar presentations
Logical and Artificial Intelligence in Games Lecture 13
Advertisements


Fuzzy Inference Systems
 Negnevitsky, Pearson Education, Lecture 5 Fuzzy expert systems: Fuzzy inference n Mamdani fuzzy inference n Sugeno fuzzy inference n Case study.
Fuzzy Expert System  An expert might say, “ Though the power transformer is slightly overloaded, I can keep this load for a while”.  Another expert.
AI – CS364 Fuzzy Logic Fuzzy Logic 3 03 rd October 2006 Dr Bogdan L. Vrusias
Fuzzy Logic and its Application to Web Caching
Contoh Soal Fuzzy.
Fuzzy Inference and Defuzzification
CS 561, Sessions This time: Fuzzy Logic and Fuzzy Inference Why use fuzzy logic? Tipping example Fuzzy set theory Fuzzy inference.
Fuzzy Logic Driven Agent Behavior
Chapter 14.7 Russell & Norvig. Fuzzy Sets  Rules of thumb frequently stated in “fuzzy” linguistic terms. John is tall. If someone is tall and well-built.
Fuzzy Expert System Fuzzy Logic
Fuzzy Expert System. Basic Notions 1.Fuzzy Sets 2.Fuzzy representation in computer 3.Linguistic variables and hedges 4.Operations of fuzzy sets 5.Fuzzy.
Fuzzy Expert Systems. Lecture Outline What is fuzzy thinking? What is fuzzy thinking? Fuzzy sets Fuzzy sets Linguistic variables and hedges Linguistic.
Fuzzy Sets and Fuzzy Logic Chapter 12 M. Tim Jones See also
FUZZY SYSTEMS. Fuzzy Systems Fuzzy Sets – To quantify and reason about fuzzy or vague terms of natural language – Example: hot, cold temperature small,
FUZZY Logic for Game Programmers
Fuzzy Sets and Fuzzification Michael J. Watts
Fuzzy Logic E. Fuzzy Inference Engine. “antecedent” “consequent”
Lecture 07 Fuzzy Reasoning
Fuzzy Expert System.
Fuzzy Logic E. Fuzzy Inference Engine. “antecedent” “consequent”
Fuzzy Medical Image Segmentation
Chapter 18 Fuzzy Reasoning.
1 Chapter 18 Fuzzy Reasoning. 2 Chapter 18 Contents (1) l Bivalent and Multivalent Logics l Linguistic Variables l Fuzzy Sets l Membership Functions l.
WELCOME TO THE WORLD OF FUZZY SYSTEMS. DEFINITION Fuzzy logic is a superset of conventional (Boolean) logic that has been extended to handle the concept.
Fuzzy Logic Dave Saad CS498. Origin Proposed as a mathematical model similar to traditional set theory but with the possibility of partial set membership.
Fuzzy Rule-based Models *Neuro-fuzzy and Soft Computing - J.Jang, C. Sun, and, E. Mizutani, Prentice Hall 1997.
Fuzzy Logic. Priyaranga Koswatta Mundhenk and Itti, 2007.
CPSC 386 Artificial Intelligence Ellen Walker Hiram College
9/3/2015Intelligent Systems and Soft Computing1 Lecture 4 Fuzzy expert systems: Fuzzy logic Introduction, or what is fuzzy thinking? Introduction, or what.
Abdul Rahim Ahmad MITM 613 Intelligent System Chapter 3b: Dealing with Uncertainty (Fuzzy Logic)
Fuzzy Rules 1965 paper: “Fuzzy Sets” (Lotfi Zadeh) Apply natural language terms to a formal system of mathematical logic
Artificial Intelligence in Game Design Lecture 6: Fuzzy Logic and Fuzzy State Machines.
Fuzzy Inference (Expert) System
Artificial Intelligence for Games Lecture 5 1 Minor Games Programming.
Logical Systems and Knowledge Representation Fuzzy Logical Systems 1.
Fuzzy Systems Michael J. Watts
Lógica difusa  Bayesian updating and certainty theory are techniques for handling the uncertainty that arises, or is assumed to arise, from statistical.
Fuzzy Sets and Control. Fuzzy Logic The definition of Fuzzy logic is a form of multi-valued logic derived frommulti-valued logic fuzzy setfuzzy set theory.
Fuzzy Inference Systems. Fuzzy inference (reasoning) is the actual process of mapping from a given input to an output using fuzzy logic. The process involves.
“Principles of Soft Computing, 2 nd Edition” by S.N. Sivanandam & SN Deepa Copyright  2011 Wiley India Pvt. Ltd. All rights reserved. CHAPTER 12 FUZZY.
Fuzzy systems. Calculate the degree of matching Fuzzy inference engine Defuzzification module Fuzzy rule base General scheme of a fuzzy system.
Homework 5 Min Max “Temperature is low” AND “Temperature is middle”
Fuzzy Expert System n Introduction n Fuzzy sets n Linguistic variables and hedges n Operations of fuzzy sets n Fuzzy rules n Summary.
Fuzzy Logic Artificial Intelligence Chapter 9. Outline Crisp Logic Fuzzy Logic Fuzzy Logic Applications Conclusion “traditional logic”: {true,false}
Type-2 Fuzzy Sets and Systems. Outline Introduction Type-2 fuzzy sets. Interval type-2 fuzzy sets Type-2 fuzzy systems.
Artificial Intelligence Techniques Knowledge Processing 2-MSc.
Fuzzy Relations( 關係 ), Fuzzy Graphs( 圖 形 ), and Fuzzy Arithmetic( 運算 ) Chapter 4.
Chapter 13 (Continued) Fuzzy Expert Systems 1. Fuzzy Rule-based Expert System 2.
Introduction to Fuzzy Logic and Fuzzy Systems
Fuzzy Logic Control What is Fuzzy Logic ? Logic and Fuzzy Logic
Artificial Intelligence CIS 342
FUZZY NEURAL NETWORKS TECHNIQUES AND THEIR APPLICATIONS
Fuzzy expert systems Fuzzy inference Mamdani fuzzy inference
Artificial Intelligence
Homework 8 Min Max “Temperature is low” AND “Temperature is middle”
Introduction to Fuzzy Logic
Artificial Intelligence and Adaptive Systems
Fuzzy logic Introduction 3 Fuzzy Inference Aleksandar Rakić
Fuzzy System Structure
منطق فازی.
Dr. Unnikrishnan P.C. Professor, EEE
FUZZIFICATION AND DEFUZZIFICATION
Homework 9 Min Max “Temperature is low” AND “Temperature is middle”
Lecture 5 Fuzzy expert systems: Fuzzy inference
Dr. Unnikrishnan P.C. Professor, EEE
Fuzzy Inference Systems
Presentation transcript:

1 Fuzzy Logic Artificial Intelligence for Games Scott Goodwin School of Computer Science See Buckland, Chapter 10

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 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 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 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 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 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 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 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 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)} = = 0.25

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 = =  DOM fairly(clever) (x) = DOM clever (x) 0.5  DOM fairly(clever) (115) = DOM clever (115) 0.5 = = 0.866

12 Fuzzy Identity Laws  DeMorgan’s Law  Associativity  Commutativity  Distributivity

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 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 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 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 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 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 Designing the DistanceToTarget FLV  The distance scale is in pixels and assumes a RavenBot is about 10 pixels wide

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 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 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 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 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 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 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 Clip the consequent  The confidence of each consequent is then used to clip the membership functions

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 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 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 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 Centroid Calculation

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 Raven Fuzzy System