Artificial Intelligence in Game Design Lecture 6: Fuzzy Logic and Fuzzy State Machines.

Slides:



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

Speed, Velocity and Acceleration
Conventional (Boolean) Set Theory: Fuzzy Set Theory © INFORM Slide 1 “Strong Fever” 40.1°C 42°C 41.4°C 39.3°C 38.7°C 37.2°C 38°C Fuzzy Set Theory:
Fuzzy Logic and Robot Control Mundhenk and Itti, 2007.
Lecture 4 Fuzzy expert systems: Fuzzy logic
Rulebase Expert System and Uncertainty. Rule-based ES Rules as a knowledge representation technique Type of rules :- relation, recommendation, directive,
Contoh Soal Fuzzy.
L-4 constant acceleration and free fall (M-3)
Artificial Intelligence in Game Design Representing NPCs as Finite State Machines.
1 Fuzzy Logic Artificial Intelligence for Games Scott Goodwin School of Computer Science See Buckland, Chapter 10.
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 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 Logic.
University of Texas at Austin CS 378 – Game Technology Don Fussell CS 378: Computer Game Technology AI – Fuzzy Logic and Neural Nets Spring 2012.
Artificial Intelligence in Game Design Intelligent Decision Making and Decision Trees.
FUZZY Logic for Game Programmers
Fuzzy Logic E. Fuzzy Inference Engine. “antecedent” “consequent”
Artificial Intelligence in Game Design Introduction to Learning.
Modeling Uniform Motion We believe that mere movement is life, and that the more velocity it has, the more it expresses vitality. -- Rabindranath Tagore.
Fuzzy Expert System.
Fuzzy Logic E. Fuzzy Inference Engine. “antecedent” “consequent”
Artificial Intelligence in Game Design Probabilistic Finite State Machines.
Artificial Intelligence in Game Design Representing NPCs as Finite State Machines.
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.
DAMN : A Distributed Architecture for Mobile Navigation Julio K. Rosenblatt Presented By: Chris Miles.
Fuzzy Logic. Priyaranga Koswatta Mundhenk and Itti, 2007.
CPSC 386 Artificial Intelligence Ellen Walker Hiram College
Fuzzy Logic Conception Introduced by Lotfi Zadeh in 1960s at Berkley Wanted to expand crisp logic.
 Definition Definition  Bit of History Bit of History  Why Fuzzy Logic? Why Fuzzy Logic?  Applications Applications  Fuzzy Logic Operators Fuzzy.
Fuzzy Inference (Expert) System
CPS 270: Artificial Intelligence Machine learning Instructor: Vincent Conitzer.
Artificial Intelligence for Games Lecture 5 1 Minor Games Programming.
Artificial Intelligence in Game Design N-Grams and Decision Tree Learning.
Free Fall J. Frank Dobie H.S.. Free Fall Free-falling object falling falls only under the influence of gravity. Free-falling object is “in a state of.
Acceleration- Change in Velocity
Artificial Intelligence in Game Design Complex Steering Behaviors and Combining Behaviors.
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.
SPEED AND ACCELERATION. MOTION  Motion occurs when an object changes position relative to a reference point  You do not need to see an object in motion.
AI Fuzzy Systems. History, State of the Art, and Future Development Sde Seminal Paper “Fuzzy Logic” by Prof. Lotfi Zadeh, Faculty in Electrical.
Could Be Significant.
Artificial Intelligence in Game Design Influence Maps and Decision Making.
Artificial Intelligence in Game Design Lecture 8: Complex Steering Behaviors and Combining Behaviors.
11/6/2001CS 638, Fall 2001 Today AI –Fuzzy Logic –Neural Nets.
Artificial Intelligence in Game Design Lecture 20: Hill Climbing and N-Grams.
Fuzzy Logic Artificial Intelligence Chapter 9. Outline Crisp Logic Fuzzy Logic Fuzzy Logic Applications Conclusion “traditional logic”: {true,false}
VECTORS  Magnitude & direction  Magnitude-how much  Direction-which way  Examples  Displacement  Velocity  Weight  Acceleration SCALARS  Magnitude.
Chap 2: Aggregation Operations on Fuzzy Sets u Goal: In this chapter we provide a number of different methodologies for aggregating fuzzy subsets. u t-norm.
Finite State Machines Logical and Artificial Intelligence in Games Lecture 3a.
Artificial Intelligence Techniques Knowledge Processing 2-MSc.
Distance and Displacement. Frames of Reference Whenever you describe something that is moving, you are comparing it with something that is assumed to.
Acceleration. Definition Any change in velocity is acceleration What are the possible causes of acceleration? Speeding up Slowing down Changing direction.
Introduction to Fuzzy Logic and Fuzzy Systems
Games and AI.
A great man who created a complete new mathematics with many practical applications.
Enemy and Friendly AIs Richard Gesick.
Fuzzy Logic 11/6/2001.
Artificial Intelligence
Homework 8 Min Max “Temperature is low” AND “Temperature is middle”
Introduction to Fuzzy Logic
Fuzzy logic Introduction 3 Fuzzy Inference Aleksandar Rakić
Dr. Unnikrishnan P.C. Professor, EEE
FUZZIFICATION AND DEFUZZIFICATION
Homework 9 Min Max “Temperature is low” AND “Temperature is middle”
Chapter 9 Section 3 Acceleration
Fuzzy Logic Colter McClure.
Dr. Unnikrishnan P.C. Professor, EEE
Presentation transcript:

Artificial Intelligence in Game Design Lecture 6: Fuzzy Logic and Fuzzy State Machines

Problems with Discrete States Characters may be in multiple states simultaneously –Particularly emotional states Hit  angry Low HP  frightened May indicate contradictory responses –Frightened  run –Angry  attack Need “intermediate” states and actions –“Somewhat angry” –“Somewhat frightened”

Problems with Discrete States Abrupt transitions between states –Exact behavior from 100 down to 10 HP –Sudden behavior change at 9 HP More realistic if behavior gradually changes as HP approaches 10 Angry Snarling Moving forward Frightened Wincing Backing away HP < 10

Problems with Discrete States Serious problem if action is continuous value –Example: Racing games Actions: Speed of car Amount to steer … –Basic idea: Near curve  slow speed Far from curve  fast speed

Problems with Discrete States Bad solution (based on discrete states) –Distance to curve > 10  120 mph –Distance to curve <= 10  60 mph Sudden transition!

Problems with Discrete States Best solution: –As get closer to curve, gradually slow down –As get further from curve, gradually speed up

Fuzzy Logic Membership function µ S (x) –“Degree” to which entity X belongs in state S –Discrete states: µ S (x) = 1  X is in state S or 0  X is not in state S Fuzzy states: µ S (x) may be any number between 0 and 1 –X may be “somewhat” in state S

Fuzzy Logic and Language Often used to quantify “natural language” hedges Example: –“Not at all”  µ S (x) = 0 –“A little”  µ S (x) = 0.2 –“Kind of”  µ S (x) = 0.4 –“Pretty”  µ S (x) = 0.6 –“Very”  µ S (x) = 0.8 –“Absolutely”  µ S (x) = 1.0

Fuzzy Logic Example Example: Oswald the Orc –Very angry µ angry (Oswald) = 0.8 –Kind of frightened µ frightened (Oswald) = 0.4 –Not at all confident µ confident (Oswald) = 0.0 Note that fuzzy memberships don’t have to add up to 1 (unlike probabilities)

Fuzzification Converting a continuous valued attribute to a fuzzy state membership Racing example: –Attribute = car’s distance from curve –Fuzzy states: Near curve Far from curve –Goal: determine membership of car in these sets –First step to determine desired speed of car Start of curve

Fuzzification Often represent as simple graphs –X axis: continuous attribute –Y axis: membership in set(s) –Example: current distance = 60 distance to curve NearFar µ near (car) = 0.6 µ far (car) = 0.4

Fuzzy Rules Fuzzy antecedent  Fuzzy conclusion Fuzzy antecedent created from fuzzification Requires fuzzy definitions of logical connectives AND, OR, and NOT. Given fuzzy membership in this What is fuzzy membership in this?

Fuzzy Connectives Usual measures: AND: µ S and T (x) = min ( µ S (x), µ T (x)) OR: µ S or T (x) = max ( µ S (x), µ T (x)) Note: this also applies if combining separate rules NOT: µ not T (x) = 1 - µ T (x)

Fuzzy Rule Example Rules: IF near curve exit AND going slow THEN accelerate IF far from curve exit AND going medium THEN accelerate Question: If near, far, slow, medium all fuzzy measures What is resulting membership in accelerate? Speed: 100 mph Distance from exit: 80

Fuzzy Rule Example distance to curve NearFar µ near (car) = 0.4 µ far (car) = 0.6 speed SlowFast µ slow (car) = 0.3 µ medium (car) = 1.0 Medium

Fuzzy Rule Example Rule 1: IF near curve exit AND going slow THEN accelerate µ accelerate ( car ) = µ near and slow ( car ) = min ( µ near ( car ), µ slow ( car )) = min(0.4, 0.3) = 0.3 Rule 2: IF far curve exit AND going medium THEN accelerate µ accelerate ( car ) = µ far and medium ( car ) = min ( µ far ( car ), µ medium ( car )) = min(0.6, 1.0) = 0.6

Fuzzy Rule Example Combining the rules: µ accelerate ( car ) = µ accelerate1 or accelerate2 ( car ) = max ( µ accelerate1 ( car ), µ accelerate2 ( car )) = max(0.3, 0.6) = 0.6 Membership of the car in accelerate = 0.6

Defuzzification Converting fuzzy state membership to appropriate actions –Higher membership in state  greater degree of action implied by state Possible problems –Conflicts if multiple actions indicated –Some actions not fuzzy (attack vs. no attack) –Many open problems!

Simple Defuzzification Create fuzzy set for action Map membership in set back to value –Assumes no conflicts with other actions based on same value –Assumes monotonic function for fuzzy set Example: µ accelerate ( car ) = 0.6  acceleration = 16 feet/second 2 feet/second Acceleration 0.6

Conflicts in Defuzzification Example rule: IF near curve entrance AND going fast THEN brake –Distance: 90  µ near (car) = 0.2 –Speed: 80  µ fast (car) = 0.15 –µ brake (car) = min (0.2, 0.15) = 0.15

Conflicts in Defuzzification Conflicting fuzzy actions: –µ accelerate ( car ) = 0.6 –µ brake ( car ) = 0.15 Intuitive idea: –Should accelerate since its membership is larger –Membership in brake should decrease acceleration to some degree

Conflicts in Defuzzification Methods: Just use largest rule (µ accelerate ( car ) = 0.6 ) –Fast to compute –Leads to uneven behavior Weighted center of mass of sets –Commonly used in AI –Slow and costly to compute Acceleration 0.6 feet/second 2 Braking 0.15

Conflicts in Defuzzification 1.Choose one value for each set –Usually its maximum value 2.Weight by memberships in each set 3.Determine average value Example: –Maximum acceleration = 30 feet/second 2 –Maximum braking = -40 feet/second 2 Weighted by membership: –Acceleration = 0.6 * 30 feet/second 2 = 18 feet/second 2 –Braking = 0.15 * -40 feet/second 2 = -6 feet/second 2 Resulting acceleration: 12 feet/second 2

Defuzzifying Discrete Actions Example: Attack/No attack (must do one or the other) Thresholding: –If fuzzy membership > threshold take action –Example: If µ angry ( orc ) > 0.7  attack If µ angry ( orc ) <= 0.7  no attack Conflicts: Take action with highest membership –Angry  attack, µ angry ( Oswald ) = 0.7 –Frightened  run, µ frightened ( Oswald ) = 0.3 Note: Fuzzy logic works best for continuous valued actions Oswald attacks!

Fuzzy State Machines Fuzzy membership in states –May be in multiple states –Transitions between states may be fuzzy –Resulting actions may be fuzzy Example: –May be confident and fearful to some degree –Transitions based on fuzzy measures “high” and “low” HP –Action (% chance of attack) is continuous valued Confident Attack 100% HP low Fearful Attack 20% HP high

Fuzzy State Machines Transitions of form treated like fuzzy and –Must be in state S1 –Stimulus T must be present µ S2 ( orc ) = min( µ S1 ( orc ), µ T ( orc ) ) Note that unless µ S2 ( orc ) = 1, it is still in S1 to some degree: µ S1 ( orc ) = 1 - µ S2 ( orc ) Note that state S2 may be indicated as a next state by many other states (including itself) –Will use max rule to determine final membership in S2 S1S2 T

Fuzzy State Machine Example Current state memberships –µ conf (Oswald) = 0.8 –µ fear (Oswald) = 0.4 Confident Attack 100% HP low Fearful Attack 40% HP high

Fuzzy State Machine Example Current HP = 13 (just took heavy hit by player) –µ low (Oswald) = 0.7 –µ high (Oswald) = 0.2 HP LowHigh

Fuzzy State Machine Example Confident  Fearful transition –µ fear (Oswald) = min ( µ conf (Oswald), µ low (Oswald)) = min (0.8, 0.7) = 0.7 –µ conf (Oswald) = 1 - µ fear (Oswald) = 0.3 Fearful  Confident transition –µ conf (Oswald) = min( µ fear (Oswald), µ high (Oswald)) = min (0.4, 0.2) = 0.2 –µ fear (Oswald) = 1 - µ conf (Oswald) = 0.8

Fuzzy State Machine Example Combining effects of transitions –µ conf (Oswald) = max (0.3, 0.2) = 0.3 –µ fear (Oswald) = max (0.7, 0.8) = 0.8 Determining current action (defuzzification) –Attack % = ( µ conf (Oswald) * 100% + µ fear (Oswald) * 20% ) / 2 = (0.4 * 100% * 20% ) / 2 = 46%