Artificial Intelligence for Games Lecture 5 1 Minor Games Programming.

Slides:



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

© Negnevitsky, Pearson Education, Lecture 4 Fuzzy expert systems: Fuzzy logic Introduction, or what is fuzzy thinking? Introduction, or what is.
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
Lecture 4 Fuzzy expert systems: Fuzzy logic
Fuzzy Inference and Defuzzification
1 Fuzzy Logic Artificial Intelligence for Games Scott Goodwin School of Computer Science See Buckland, Chapter 10.
Fuzzy Logic Driven Agent Behavior
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 Logic for Game Programmers
Fuzzy Logic E. Fuzzy Inference Engine. “antecedent” “consequent”
Computer Intelligence and Soft Computing
Fuzzy Expert System.
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.
Fuzzy Logic Dave Saad CS498. Origin Proposed as a mathematical model similar to traditional set theory but with the possibility of partial set membership.
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.
Fuzzy Rule-based Models *Neuro-fuzzy and Soft Computing - J.Jang, C. Sun, and, E. Mizutani, Prentice Hall 1997.
BEE4333 Intelligent Control
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.
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 Logic Conception Introduced by Lotfi Zadeh in 1960s at Berkley Wanted to expand crisp logic.
Fuzzy Sets Introduction/Overview Material for these slides obtained from: Modern Information Retrieval by Ricardo Baeza-Yates and Berthier Ribeiro-Neto.
Fuzzy Rules 1965 paper: “Fuzzy Sets” (Lotfi Zadeh) Apply natural language terms to a formal system of mathematical logic
Fuzzy expert systems Chapter #9.
Artificial Intelligence in Game Design Lecture 6: Fuzzy Logic and Fuzzy State Machines.
Fuzzy Expert Systems. 2 Motivation On vagueness “Everything is vague to a degree you do not realise until you have tried to make it precise.” Bertrand.
Fuzzy Inference (Expert) System
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.
Fuzzy Inference Systems
Basic Concepts of Fuzzy Logic Apparatus of fuzzy logic is built on: Fuzzy sets: describe the value of variables Linguistic variables: qualitatively and.
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.
AI Fuzzy Systems. History, State of the Art, and Future Development Sde Seminal Paper “Fuzzy Logic” by Prof. Lotfi Zadeh, Faculty in Electrical.
Fuzzy Expert System n Introduction n Fuzzy sets n Linguistic variables and hedges n Operations of fuzzy sets n Fuzzy rules n Summary.
Chapter 19. Fuzzy Reasoning
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.
Fuzzy Relations( 關係 ), Fuzzy Graphs( 圖 形 ), and Fuzzy Arithmetic( 運算 ) Chapter 4.
© Negnevitsky, Pearson Education, Lecture 5 Fuzzy expert systems: Fuzzy inference Mamdani fuzzy inference Mamdani fuzzy inference Sugeno fuzzy inference.
Lecture 4 Fuzzy expert systems: Fuzzy logic n Introduction, or what is fuzzy thinking? n Fuzzy sets n Linguistic variables and hedges n Operations of fuzzy.
Chapter 13 (Continued) Fuzzy Expert Systems 1. Fuzzy Rule-based Expert System 2.
Artificial Intelligence CIS 342
Fuzzy expert systems Fuzzy inference Mamdani fuzzy inference
Artificial Intelligence
Introduction to Fuzzy Logic
Artificial Intelligence and Adaptive Systems
Fuzzy logic Introduction 3 Fuzzy Inference Aleksandar Rakić
Dr. Unnikrishnan P.C. Professor, EEE
FUZZIFICATION AND DEFUZZIFICATION
Lecture 5 Fuzzy expert systems: Fuzzy inference
Fuzzy Logic Colter McClure.
Dr. Unnikrishnan P.C. Professor, EEE
Hybrid intelligent systems:
Fuzzy Inference Systems
© Negnevitsky, Pearson Education, Lecture 4 Fuzzy expert systems: Fuzzy logic Introduction, or what is fuzzy thinking? Introduction, or what is.
Fuzzy Logic KH Wong Fuzzy Logic v.9a.
Presentation transcript:

Artificial Intelligence for Games Lecture 5 1 Minor Games Programming

Artificial Intelligence for Games 2  Theory:  Short introduction to Fuzzy Logic Jan Verhoeven

Theory: Fuzzy Logic, (see study book: chapter 10) 3  Crisp and Fuzzy Sets with Operators  Fuzzy Rules  Fuzzy Inference Procedure  Coding a Fuzzy Logic Module  Fuzzy Logic Classes in Raven  The Combs Method

Fuzzy Logic: how to make perfect cheese on toast: 4 1. Cut two slices of bread medium thick. 2. Turn the heat on the griddle on 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.

intermezzo 5  What is medium thick ?  1 cm?  And what about 0,999 cm?  Discrete intervals are sometimes to rigid.

Fuzzy Logic 6  Fuzzy logic, invented by a man named Lotfi Zadeh in the mid-sixties, enables a computer to reason about linguistic terms and rules in a way similar to humans

Fuzzy rule-based inference 7

Crisp Sets, an object belongs to a set or it doesn’t 8

Crisp Sets, a graphical way of showing your IQ 9  Dumb = {70, 71, 72, … 89}  Average = {90, 91, 92, … 109}  Clever = {110, 111, 112, … 129}

Fuzzy Sets 10  Dumb = {60, 61, …, 100}  Average = {80, 81, … 120}  Clever = {100, 101, … 140}

Defining Fuzzy Boundaries with Membership Functions 11 DOM (degree of membership)

fuzzy set, Membership value, DOM 12 The dotted line shows the IQ of 115, which is a member of two sets: m(115) = { Average/0.25, Clever/0.75 } Another example: m(80) = {Dumb/1.0, Average/0.0} = {Dumb/1.0} Note: 0.25 = membership degree (DOM)

Exercise Time  Student X owns a IQ of 110  What are his degrees of membership in Dumb, Average and Clever?

Figure 10.6: The set of people who are Average AND Clever 14

Figure 10.7: The set of people who are Average OR Clever 15

Figure 10.8: The complement of Clever 16

Exercise Time -2-:Draw Fuzzy Sets The fuzzy set A = NOT (Average OR Dumb) 2. The fuzzy set: B = (Average AND Clever) OR (NOT Dumb)

Exercise Time What is DOM of student X with an IQ of 110 in fuzzy set A? 2. And in fuzzy set B? 3. Which IQ belongs to a DOM value of 0.5 in fuzzy set A? 4. And in fuzzy set B?

Hedges 19  Hedges are unary operators that can be employed to modify the meaning of a fuzzy set. Two commonly used hedges are VERY and FAIRLY

Fuzzy Modifiers 20  Possible fuzzy definitions very(a) = a 2 extremely(a) = a 3 moreorless(a) = a 1/2 slightly(a) = a 1/3 exactly(a) = a +  always(a) = a 0  Example: DOM(90) in fuzzy set: Very(Dumb) is (0.5) 2

Fuzzy Linguistic Variables (or FLV) 21  A fuzzy linguistic variable (or FLV) is the composition of one or more fuzzy sets to represent a concept or domain qualitatively.  Given our earlier example, the sets Dumb, Average, and Clever are members of the fuzzy linguistic variable IQ.  This can be written in set notation as:  IQ ={Dumb, Average, Clever}

Designing FLV’s 22 There are a couple of important guidelines to adhere to when designing FLVs. They are:  For any vertical line (representing an input value) drawn through the FLV, the sum of the DOMs in each of the fuzzy sets it intersects with should be approximately 1. This ensures a smooth transition between values over the FLV's fuzzy manifold (the combined shape of all membership sets).  For any vertical line drawn through the FLV, it should only intersect with two or fewer fuzzy sets.

Badly designed FLV’s: 23

Fuzzy Rules 24  Fuzzy rules are comprised of an antecedent and a consequent in the form:  IF antecedent THEN consequent  The antecedent represents a condition and the consequent describes the consequence if that condition is satisfied. This type of rule is familiar to all programmers.

Fuzzy Rules Examples 25  IF Target_isFarRight THEN Turn_QuicklyToRight  IF VERY(Enemy_BadlyInjured) THEN Behavior_Aggressive  IF Target_isFarAway AND Allegiance_isEnemy THEN Shields_OnLowPower  IF MOREORLESS(Coffee_Break_Time) AND EXTREMELY(Sleepy) THEN Take_A_Cup

Fuzzy Inference 26 This is where we present the system with some values to see which rules fire and to what degree. Fuzzy inference follows these steps: 1. For each rule, a) For each antecedent, calculate the degree of membership of the input data. b) Calculate the rule's inferred conclusion based upon the values determined in 1a. 2. Combine all the inferred conclusions into a single conclusion (a fuzzy set). 3. For crisp values, the conclusion from 2 must be defuzzified.

Fuzzy rule-based inference 27

An Example: Weapon Selection in RAVEN 28 Steps: 1. Designing FLVs for Weapon Selection 2. Designing the Rule Set for Weapon Selection 3. Fuzzy Inference To keep the example simple, we'll say the desirability of selecting a particular weapon from the inventory is dependent on two factors: the distance to the target and the amount of ammo

Example Raven: FLV Desirability (consequent) 29

Example Raven: antecedent: Distance to Target 30

Example Raven: Designing the Ammo Status FLV (for each weapon type) 31

Example Raven: Designing the Rule Set for Weapon Selection  To cover all the possibilities, a rule must be created for each possible combination of antecedent sets.  The FLVs Ammo Status and Distance to Target each contain three member sets, so to cover every combination nine rules must be defined.  The rules must be defined by an expert user!

Example Raven: Designing the Rule Set for Weapon Selection  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

Example Raven: Fuzzy Inference 34  Let's now work through these steps using some of the rules we've created for weapon selection and some crisp input values.  Let's say the target is at a distance of 200 pixels and the amount of ammo remaining is 8 rockets.  One rule at a time then…

Example Raven: Fuzzy Inference, Rule One 35 IF Target_Far AND Ammo_Loads THEN Desirable

Example Raven: Fuzzy Inference, Rule Two 36 IF Target_Far AND Ammo_Okay THEN Undesirable

Example Raven: Fuzzy Inference, Rule Three 37 IF Target_Far AND Ammo_Low THEN Undesirable

EXERCISE TIME 38  Fuzzy Inference, Rule 5:  IF Target_Medium AND Ammo_Okay THEN VeryDesirable  Draw and compute the inferred conclusion for VeryDesirable

Example Raven: Rules one to nine in fuzzy associative matrix (FAM) 39

Inferred conclusions 40  Undesirable0.33 (maximum value of 0.33 and 0.2)  Desirable0.2  Very Desirable0.67

The inferred results of processing the rule set for weapon selection 41

Combining the conclusions 42

Defuzzification 43  Now that we have a composite fuzzy set representing the inferred conclusion of all the rules in the rule base, it's time to turn the process around and convert this output set into a single crisp value. This is achieved by a process called defuzzification.  Many techniques are possible (see study book):  Mean of Maximum (MOM)  Centroid  Average of Maxima (MaxAv)

Example Raven: Defuzzification 44  Mean of Maximum (MOM)  83  Centroid  62  Average of Maxima (MaxAv) 

Example Raven: Selection 45 If this whole 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.

Homework 46  Homework  Study Chapter 10 Fuzzy Logic, pages 415 to 437.

Practice (next TUESDAY) 47  Program a fuzzy (console) application in C++.  You must use the FuzzyModule Class (and others) of Buckland, see study book pages 437 to 452. The sources will be on Blackboard.  For an example see weapon selection code in Raven.  TIP: Use your study book during next practice!