Fuzzy Logic Driven Agent Behavior

Slides:



Advertisements
Similar presentations
Fuzzy Inference Systems. Review Fuzzy Models If then.
Advertisements

 Negnevitsky, Pearson Education, Lecture 5 Fuzzy expert systems: Fuzzy inference n Mamdani fuzzy inference n Sugeno fuzzy inference n Case study.
AI – CS364 Fuzzy Logic Fuzzy Logic 3 03 rd October 2006 Dr Bogdan L. Vrusias
Fuzzy Inference and Defuzzification
ANALYSIS OF COSTS.
Introduction to Fuzzy Control Lecture 10.1 Appendix E.
1 Fuzzy Logic Artificial Intelligence for Games Scott Goodwin School of Computer Science See Buckland, Chapter 10.
Fuzzy Logic Steve Foster.
An Introduction to Type-2 Fuzzy Sets and Systems
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 Logic for Game Programmers
Fuzzy Logic E. Fuzzy Inference Engine. “antecedent” “consequent”
GATE Reactive Behavior Modeling Fuzzy Logic (GATE-561) Dr.Çağatay ÜNDEĞER Instructor Middle East Technical University, GameTechnologies Bilkent University,
Fuzzy Expert System.
FURTHER APPLICATIONS OF INTEGRATION Probability In this section, we will learn about: The application of calculus to probability.
Fuzzy Logic E. Fuzzy Inference Engine. “antecedent” “consequent”
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.
Ming-Feng Yeh General Fuzzy Systems A fuzzy system is a static nonlinear mapping between its inputs and outputs (i.e., it is not a dynamic system).
Fuzzy Logic Dave Saad CS498. Origin Proposed as a mathematical model similar to traditional set theory but with the possibility of partial set membership.
1 Seventh Lecture Error Analysis Instrumentation and Product Testing.
Short Term Load Forecasting with Expert Fuzzy-Logic System
Introduction to Rule-Based Systems, Expert Systems, Fuzzy Systems Introduction to Rule-Based Systems, Expert Systems, Fuzzy Systems (sections 2.7, 2.8,
The Equivalence between fuzzy logic controllers and PD controllers for single input systems Professor: Chi-Jo Wang Student: Nguyen Thi Hoai Nam Student.
What's The Balance Point?
Fuzzy Rule-based Models *Neuro-fuzzy and Soft Computing - J.Jang, C. Sun, and, E. Mizutani, Prentice Hall 1997.
Fuzzy Logic. Sumber (download juga): 0logic%20toolbox.pdf
Rule-Based Fuzzy Model. In rule-based fuzzy systems, the relationships between variables are represented by means of fuzzy if–then rules of the following.
Fuzzy Logic. Priyaranga Koswatta Mundhenk and Itti, 2007.
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)
Chapter 3: Central Tendency. Central Tendency In general terms, central tendency is a statistical measure that determines a single value that accurately.
F OUNDATIONS OF S TATISTICAL I NFERENCE. D EFINITIONS Statistical inference is the process of reaching conclusions about characteristics of an entire.
Chapter 11 Analysis and Explanation. Chapter 11 Outline Explain how CI systems do what they do Only a few methodologies are discussed here Sensitivity.
Fuzzy Rules 1965 paper: “Fuzzy Sets” (Lotfi Zadeh) Apply natural language terms to a formal system of mathematical logic
Lecture 5 Fuzzy expert systems: Fuzzy inference Mamdani fuzzy inference Mamdani fuzzy inference Sugeno fuzzy inference Sugeno fuzzy inference Case study.
Department of Electrical Engineering, Southern Taiwan University Robotic Interaction Learning Lab 1 The optimization of the application of fuzzy ant colony.
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.
Chapter 7 Sampling Distributions Statistics for Business (Env) 1.
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.
“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.
Fuzzy Inference Systems
Chapter 4: Fuzzy Inference Systems Introduction (4.1) Mamdani Fuzzy models (4.2) Sugeno Fuzzy Models (4.3) Tsukamoto Fuzzy models (4.4) Other Considerations.
Fuzzy Expert System n Introduction n Fuzzy sets n Linguistic variables and hedges n Operations of fuzzy sets n Fuzzy rules n Summary.
INTEGRALS We saw in Section 5.1 that a limit of the form arises when we compute an area. We also saw that it arises when we try to find the distance traveled.
1 Lecture 4 The Fuzzy Controller design. 2 By a fuzzy logic controller (FLC) we mean a control law that is described by a knowledge-based system consisting.
Type-2 Fuzzy Sets and Systems. Outline Introduction Type-2 fuzzy sets. Interval type-2 fuzzy sets Type-2 fuzzy systems.
Dinner for Two. Fuzzify Inputs Apply Fuzzy Operator.
© Negnevitsky, Pearson Education, Lecture 5 Fuzzy expert systems: Fuzzy inference Mamdani fuzzy inference Mamdani fuzzy inference Sugeno fuzzy inference.
VIDYA PRATISHTHAN’S COLLEGE OF ENGINEERING, BARAMATI.
Chapter 13 (Continued) Fuzzy Expert Systems 1. Fuzzy Rule-based Expert System 2.
Fuzzy Inference System
Artificial Intelligence CIS 342
Fuzzy Systems Michael J. Watts
Fuzzy expert systems Fuzzy inference Mamdani fuzzy inference
Artificial Intelligence
Introduction to Fuzzy Logic
Fuzzy logic Introduction 3 Fuzzy Inference Aleksandar Rakić
Dr. Unnikrishnan P.C. Professor, EEE
Dr. Unnikrishnan P.C. Professor, EEE
FUZZIFICATION AND DEFUZZIFICATION
Fuzzy Logic Colter McClure.
Dr. Unnikrishnan P.C. Professor, EEE
Chapter 3: Central Tendency
Fuzzy Logic KH Wong Fuzzy Logic v.9a.
Presentation transcript:

Fuzzy Logic Driven Agent Behavior Prof. Dr. Taoufik Nouri Nouri@Nouri.ch 29.03.2014 The primary text for the course is Ref.[1]

Fuzzy Logic Goal: Master How the raven is using fuzzy logic. Prof. Dr. Lotfi Zadeh father of Fuzzy Logic

Fuzzy Sets Fuzzy Variable IQ Ryan with IQ=115 Є Clever with m = 0.75 Є Average with m = 0.25 m is membership coefficient Fuzzy Variable: Distance to Target

Fuzzy Set Operators Average AND Clever OR = + Average OR Clever NOT NOT Clever

Definition A fuzzy set is defined by a membership function. These functions can be any arbitrary shape but are typically triangular or trapezoidal. Notice how they define a gradual transition from regions completely outside the set to regions completely within the set, thereby enabling a value to have partial membership to a set.

Hedges

Fuzzy Rules Fuzzy rules are comprised of an antecedent and a consequent in the form: IF antecedent THEN consequent = new FuzzyRule(antecedent, consequence) The antecedent represents a condition and the consequent describes the consequence if that condition is satisfied. The difference with fuzzy rules is that unlike conventional rules where the consequent either fires or not, in fuzzy systems the consequent can fire to a matter of degree. Here are some examples of fuzzy rules: IF Target_isFarRight THEN Turn_QuicklyToRight IF VERY(Enemy_BadlyInjured) THEN Behavior_Aggressive IF Target_isFarAway AND Allegiance_isEnemy THEN Shields_OnLowPower IF Ball_isCloseToHole AND Green_isLevel THEN HitBall_Gently AND HitBall_DirectlyAtHole IF (Bend_HairpinLeft OR Bend_HairpinRight) AND Track_SlightlyWet THEN Speed_VerySlow

How Raven Uses the Fuzzy Logic Each Raven weapon owns an instance of a fuzzy module, with rules specific to the weapon. All weapons have the method GetDesirability, which updates the fuzzy module and returns a crisp desirability score. The desirability of selecting a particular weapon is dependent on two factors: the distance to the target and the amount of ammo.

Fuzzy Variable by Raven

Fuzzy Module FuzzyVariable& DistToTarget = fm.CreateFLV("DistToTarget"); FzSet Target_Close = DistToTarget.AddLeftShoulderSet("Target_Close", 0, 25, 150); FzSet Target_Medium = DistToTarget.AddTriangularSet("Target_Medium", 25, 150, 300); FzSet Target_Far = DistToTarget.AddRightShoulderSet("Target_Far", 150, 300, 500);

How Raven Uses the Fuzzy Logic Weapons & Projectiles: Weapon Blaster Weapon Railgun Weapon Rocket Luncher Weapon Shotgun Fuzzy logic decides which weapon can be used for the next shot based on the distance to the ennemy, the AmmoStatus and the Desirability. The weapon have specific rules

Weapon Blaster void Blaster::InitializeFuzzyModule() { FuzzyVariable& DistToTarget = m_FuzzyModule.CreateFLV("DistToTarget"); FzSet& Target_Close = DistToTarget.AddLeftShoulderSet("Target_Close",0,25,150); FzSet& Target_Medium = DistToTarget.AddTriangularSet("Target_Medium",25,150,300); FzSet& Target_Far = DistToTarget.AddRightShoulderSet("Target_Far",150,300,1000); FuzzyVariable& Desirability = m_FuzzyModule.CreateFLV("Desirability"); FzSet& VeryDesirable = Desirability.AddRightShoulderSet("VeryDesirable", 50, 75, 100); FzSet& Desirable = Desirability.AddTriangularSet("Desirable", 25, 50, 75); FzSet& Undesirable = Desirability.AddLeftShoulderSet("Undesirable", 0, 25, 50); m_FuzzyModule.AddRule(Target_Close, Desirable); m_FuzzyModule.AddRule(Target_Medium, FzVery(Undesirable)); m_FuzzyModule.AddRule(Target_Far, FzVery(Undesirable)); }

Weapon Railgun void RailGun::InitializeFuzzyModule() { FuzzyVariable& DistanceToTarget = m_FuzzyModule.CreateFLV("DistanceToTarget"); FzSet& Target_Close = DistanceToTarget.AddLeftShoulderSet("Target_Close", 0, 25, 150); FzSet& Target_Medium = DistanceToTarget.AddTriangularSet("Target_Medium", 25, 150, 300); FzSet& Target_Far = DistanceToTarget.AddRightShoulderSet("Target_Far", 150, 300, 1000); FuzzyVariable& Desirability = m_FuzzyModule.CreateFLV("Desirability"); FzSet& VeryDesirable = Desirability.AddRightShoulderSet("VeryDesirable", 50, 75, 100); FzSet& Desirable = Desirability.AddTriangularSet("Desirable", 25, 50, 75); FzSet& Undesirable = Desirability.AddLeftShoulderSet("Undesirable", 0, 25, 50); FuzzyVariable& AmmoStatus = m_FuzzyModule.CreateFLV("AmmoStatus"); FzSet& Ammo_Loads = AmmoStatus.AddRightShoulderSet("Ammo_Loads", 15, 30, 100); FzSet& Ammo_Okay = AmmoStatus.AddTriangularSet("Ammo_Okay", 0, 15, 30); FzSet& Ammo_Low = AmmoStatus.AddTriangularSet("Ammo_Low", 0, 0, 15); m_FuzzyModule.AddRule(FzAND(Target_Close, Ammo_Loads), FzFairly(Desirable)); m_FuzzyModule.AddRule(FzAND(Target_Close, Ammo_Okay), FzFairly(Desirable)); m_FuzzyModule.AddRule(FzAND(Target_Close, Ammo_Low), Undesirable); m_FuzzyModule.AddRule(FzAND(Target_Medium, Ammo_Loads), VeryDesirable); m_FuzzyModule.AddRule(FzAND(Target_Medium, Ammo_Okay), Desirable); m_FuzzyModule.AddRule(FzAND(Target_Medium, Ammo_Low), Desirable); m_FuzzyModule.AddRule(FzAND(Target_Far, Ammo_Loads), FzVery(VeryDesirable)); m_FuzzyModule.AddRule(FzAND(Target_Far, Ammo_Okay), FzVery(VeryDesirable)); m_FuzzyModule.AddRule(FzAND(Target_Far, FzFairly(Ammo_Low)), VeryDesirable); }

RocketLauncher void RocketLauncher::InitializeFuzzyModule() { FuzzyVariable& DistToTarget = m_FuzzyModule.CreateFLV("DistToTarget"); FzSet& Target_Close = DistToTarget.AddLeftShoulderSet("Target_Close",0,25,150); FzSet& Target_Medium = DistToTarget.AddTriangularSet("Target_Medium",25,150,300); FzSet& Target_Far = DistToTarget.AddRightShoulderSet("Target_Far",150,300,1000); FuzzyVariable& Desirability = m_FuzzyModule.CreateFLV("Desirability"); FzSet& VeryDesirable = Desirability.AddRightShoulderSet("VeryDesirable", 50, 75, 100); FzSet& Desirable = Desirability.AddTriangularSet("Desirable", 25, 50, 75); FzSet& Undesirable = Desirability.AddLeftShoulderSet("Undesirable", 0, 25, 50); FuzzyVariable& AmmoStatus = m_FuzzyModule.CreateFLV("AmmoStatus"); FzSet& Ammo_Loads = AmmoStatus.AddRightShoulderSet("Ammo_Loads", 10, 30, 100); FzSet& Ammo_Okay = AmmoStatus.AddTriangularSet("Ammo_Okay", 0, 10, 30); FzSet& Ammo_Low = AmmoStatus.AddTriangularSet("Ammo_Low", 0, 0, 10); m_FuzzyModule.AddRule(FzAND(Target_Close, Ammo_Loads), Undesirable); m_FuzzyModule.AddRule(FzAND(Target_Close, Ammo_Okay), Undesirable); m_FuzzyModule.AddRule(FzAND(Target_Close, Ammo_Low), Undesirable); m_FuzzyModule.AddRule(FzAND(Target_Medium, Ammo_Loads), VeryDesirable); m_FuzzyModule.AddRule(FzAND(Target_Medium, Ammo_Okay), VeryDesirable); m_FuzzyModule.AddRule(FzAND(Target_Medium, Ammo_Low), Desirable); m_FuzzyModule.AddRule(FzAND(Target_Far, Ammo_Loads), Desirable); m_FuzzyModule.AddRule(FzAND(Target_Far, Ammo_Okay), Undesirable); m_FuzzyModule.AddRule(FzAND(Target_Far, Ammo_Low), Undesirable); }

ShotGun void ShotGun::InitializeFuzzyModule() { FuzzyVariable& DistanceToTarget = m_FuzzyModule.CreateFLV("DistanceToTarget"); FzSet& Target_Close = DistanceToTarget.AddLeftShoulderSet("Target_Close", 0, 25, 150); FzSet& Target_Medium = DistanceToTarget.AddTriangularSet("Target_Medium", 25, 150, 300); FzSet& Target_Far = DistanceToTarget.AddRightShoulderSet("Target_Far", 150, 300, 1000); FuzzyVariable& Desirability = m_FuzzyModule.CreateFLV("Desirability"); FzSet& VeryDesirable = Desirability.AddRightShoulderSet("VeryDesirable", 50, 75, 100); FzSet& Desirable = Desirability.AddTriangularSet("Desirable", 25, 50, 75); FzSet& Undesirable = Desirability.AddLeftShoulderSet("Undesirable", 0, 25, 50); FuzzyVariable& AmmoStatus = m_FuzzyModule.CreateFLV("AmmoStatus"); FzSet& Ammo_Loads = AmmoStatus.AddRightShoulderSet("Ammo_Loads", 30, 60, 100); FzSet& Ammo_Okay = AmmoStatus.AddTriangularSet("Ammo_Okay", 0, 30, 60); FzSet& Ammo_Low = AmmoStatus.AddTriangularSet("Ammo_Low", 0, 0, 30); m_FuzzyModule.AddRule(FzAND(Target_Close, Ammo_Loads), VeryDesirable); m_FuzzyModule.AddRule(FzAND(Target_Close, Ammo_Okay), VeryDesirable); m_FuzzyModule.AddRule(FzAND(Target_Close, Ammo_Low), VeryDesirable); m_FuzzyModule.AddRule(FzAND(Target_Medium, Ammo_Loads), VeryDesirable); m_FuzzyModule.AddRule(FzAND(Target_Medium, Ammo_Okay), Desirable); m_FuzzyModule.AddRule(FzAND(Target_Medium, Ammo_Low), Undesirable); m_FuzzyModule.AddRule(FzAND(Target_Far, Ammo_Loads), Desirable); m_FuzzyModule.AddRule(FzAND(Target_Far, Ammo_Okay), Undesirable); m_FuzzyModule.AddRule(FzAND(Target_Far, Ammo_Low), Undesirable); }

Worked Example Rule 1. IF Target_Far AND Ammo_Loads THEN Desirable Rule 2. IF Target_Far AND Ammo_Okay THEN Undesirable Rule 3. IF Target_Far AND Ammo_Low THEN Undesirable Rule 4. IF Target_Medium AND Ammo_Loads THEN VeryDesirable Rule 5. IF Target_Medium AND Ammo_Okay THEN VeryDesirable Rule 6. IF Target_Medium AND Ammo_Low THEN Desirable Rule 7. IF Target_Close AND Ammo_Loads THEN Undesirable Rule 8. IF Target_Close AND Ammo_Okay THEN Undesirable Rule 9. IF Target_Close AND Ammo_Low THEN Undesirable

Worked Example Let's say the target is at a distance of 200 pixels and the amount of ammo remaining is 8 rockets. Rule 1 IF Target_Far AND Ammo_Loads THEN Desirable The degree of membership of the value 200 to the set Target_Far is 0.33. The degree of membership of the value 8 in the set Ammo_Loads is 0. The AND operator results in the minimum of these values so the inferred conclusion for Rule 1 is Desirable =0. In other words, the rule doesn't fire.

Worked Example Rule 2 IF Target_Far AND Ammo_Okay THEN Undesirable For the second rule the degree of membership of the value 200 to the set Target_Far is 0.33. The degree of membership of the value 8 in the set Ammo_Okay is 0.78. The inferred conclusion for Rule 2 therefore is Undesirable = 0.33.

Worked Example Rule 3 IF Target_Far AND Ammo_Low THEN Undesirable Appling the same values to the third rule, the degree of membership of the value 200 to the set Target_Far is 0.33. The degree of membership of the value 8 in the set Ammo_Low is 0.2. The inferred conclusion for Rule 3 therefore is Undesirable = 0.2.

Worked Example We can continue inferencing the rules. Here is summurized result in fuzzy associative matrix, or FAM The FAM for the weapon selection rule base given the input values target distance = 200 and ammo status = 8. The shaded cells highlight rules that have fired. Note that VeryDesirable has fired once to a degree of 0.67. Desirable has fired once to a degree of 0.2, and Undesirable has fired twice with the degrees 0.2 and 0.33. One way to think of these values is as confidence levels.

Worked Example: Combining the conclusions The next step is to combine the inferred results into a single fuzzy manifold

Defuzzification: Mean of Maximum (MOM) The mean of maximum — MOM for short — method of defuzzification calculates the average of those output values that have the highest confidence degrees. Figure 10.21 shows how this technique can be used to determine a crisp value from the output distribution for Desirability calculated earlier. The mean of maximum method results in a desirability score of 83. One problem with this method is it doesn't take into account those sets in the output that do not have confidences equal to the highest (like those shown in the figure in gray), which can bias the resultant crisp value to one end of the domain.

Defuzzification: Centroid The centroid method is the most accurate but is also the most complex to calculate. It works by determining the center of mass of the output sets. If you imagine each member set of the output set cut out of card stock and then glued together to form the shape of the fuzzy manifold, the center of mass is the position where the resultant shape would balance if placed on a ruler.

Defuzzification: Centroid The centroid of a fuzzy manifold is calculated by slicing up the manifold into s sample points and calculating the sum of the contribution of the DOM at each sample point to the total, divided by the sum of the DOMs of the samples. Value Undesirable Desirable VeryDesirable Sum 10 0.33 20 30 0.2 0.53 40 50 60 0.4 0.6 70 0.67 0.87 80 90 100

Defuzzification: Average of Maxima (MaxAv) The maximum or representative value of a fuzzy set is the value where membership in that set is 1. For triangular sets this is the simply the value at the midpoint; for sets containing plateaus — such as right shoulder, left shoulder, and trapezoidal sets — this value is the average of the values at the beginning and end of the plateau. The average of maxima (MaxAv for short) defuzzification method scales the representative value of each consequent by its confidence and takes the average, like so:

We started with crisp values (distance to target = 200, ammo status = 8) to fuzzy sets, to inference, and back to a crisp value representing the desirability of using the rocket launcher (83, 62, or 60.625 depending on the defuzzification method). If this process is repeated for each weapon type a bot is carrying, it's a simple matter to select the one with the highest desirability score to be the weapon the bot should use given its current situation.

Fuzzy Module Class

Conclusion You should now have an understanding of the theory behind fuzzy logic and it's application.

Exercice Draw the fuzzy variables of the Rocket Launcher, apply the fuzzy rules and make the inference. How would you read the following rules: m_FuzzyModule.AddRule(Target_Close, Desirable); m_FuzzyModule.AddRule(Target_Medium, FzVery(Undesirable)); m_FuzzyModule.AddRule(Target_Far, FzVery(Undesirable));