Download presentation
Presentation is loading. Please wait.
Published byKristian Carroll Modified over 9 years ago
1
GATE-561 1 Reactive Behavior Modeling Fuzzy Logic (GATE-561) Dr.Çağatay ÜNDEĞER Instructor Middle East Technical University, GameTechnologies Bilkent University, Computer Engineering & General Manager SimBT Inc. e-mail : cagatay@undeger.com Game Technologies Program – Middle East Technical University – Fall 2009
2
GATE-561 2 Outline Introduction to Reactive Behaviors Fuzzy Logic
3
GATE-561 3 Reactive Behaviors A simple decision is taken immediately depending on the developing situation For instance, –Lying down when someone is shooting at you –Breaking when the car in front of you breaks
4
GATE-561 4 Reactive Behaviors Reactive agents: –Simple reflex agents –Reflex agents with internal state
5
GATE-561 5 Simple Reflect Agents In each step: –Gets a set of percepts (current state) Learn “what the world I sense now is like” –Performs rule matching on current state –Takes decision without memorizing the past Answer “what action I should do now” by using condition- action rules –Performs the selected action/s Change the environment
6
GATE-561 6 Reflect Agents with Int. State In each step: –Gets a set of percepts (current state) Learn “what the world I sense now is like” –Integrates past state to current state to get an enriched current state (internal state) Keep track of the world and estimate “what the world is like now” –Performs rule matching on current state –Takes decision Answer “what action I should do now” by using condition-action rules –Performs the selected action/s Change the environment
7
GATE-561 7 Reactive Behavior Modeling Inputs: Internal / Current State Variables p1a1 p2a2 p3a3 Outputs: Decisions / Actions An ordinary table A complex reactive algorithm Decision Process
8
GATE-561 8 Fuzzy Logic A form of multi-valued logic –Derived from fuzzy set theory –To deal with reasoning that is approximate rather than precise. Since it takes some inputs and gives some immediate outputs –It can be used to model reactive behaviors.
9
GATE-561 9 Traditional Logic vs Fuzzy Logic Traditional logic: –Manipulates “crisp sets”. –A crisp set is a set for which a given element either belongs to the set or it doesn’t. –Therefore the degree of truth of a statement is either 0 or 1. Fuzzy logic: –Has membership values between 0 and 1.
10
GATE-561 10 Traditional Logic vs Fuzzy Logic A crisp set: –Does not give us “How much” something is in a set, –Works fine for black-and-white scenarios, which are not very common in real world.
11
GATE-561 11 Traditional Logic vs Fuzzy Logic Assume that we make a set of all tall people. If we decide that 1.8 meters is tall, –We will have a function that Returns 1, –If a person is above 1.8 meters and Returns 0, –Otherwise. Saying that “a people with 1.79 meters height is not tall” will surely be silly.
12
GATE-561 12 Representation in Fuzzy Logic In fuzzy logic, –We will represent “how tall a person is” with a continuous function. 1 1.8 m 1.65 m Tall Height
13
GATE-561 13 Representation in Fuzzy Logic In fuzzy logic, –We will represent “a person that is about 1.65 m tall” with a continuous function. 1 1.65 m 1.6 m About 1.65 m tall Height 1.7 m
14
GATE-561 14 Fuzzy Logic Operations We can use operations in fuzzy logic: –AND, OR, NOT Defined as the minimum, maximum, and complement; Called the Zadeh operators. So for the fuzzy variables x and y: –NOT x = (1 - truth(x)) –x AND y = minimum(truth(x), truth(y)) –x OR y = maximum(truth(x), truth(y))
15
GATE-561 15 Fuzzy Logic Operations AND Operation 1 1.8 m 1.65 m Tall Height 1.7 m1. 6 m About 1.65 m tall AND
16
GATE-561 16 Fuzzy Logic Operations OR Operation 1 1.8 m 1.65 m Tall Height 1.7 m1. 6 m About 1.65 m tall OR
17
GATE-561 17 Fuzzy Logic Operations NOT Operation 1 1.8 m 1.65 m Tall Height 1.7 m1. 6 m NOT Tall
18
GATE-561 18 Fuzzy Control Rules are usually expressed in the form: –IF variable IS property THEN action A simple temperature regulator that uses a fan might look like this: –IF temperature IS very cold THEN stop fan –IF temperature IS cold THEN turn down fan –IF temperature IS normal THEN maintain level –IF temperature IS hot THEN speed up fan
19
GATE-561 19 Defuzzification There is no "ELSE“ All of the rules are evaluated, –Since the temperature might be "cold" and "normal" at the same time to different degrees. All matching rules are considered together weighted with their trueness –Using a defuzzification method.
20
GATE-561 20 Car Driving Sample We want to: –Model a road traffic –Have cars: Follow each other on a lane, Speed up or slow down realistically.
21
GATE-561 21 Car Driving Sample We have two linguistic variables: –Distance between this car and the one in front of this. –Distance deviation between this car and the one in front of this. If space is growing –Have positive distance deviation If space is shrinking –Have negative distance deviation Otherwise –Have zero distance deviation
22
GATE-561 22 Some of the Rules If distance deviation is zero and distance is about 2 cars length, –Maintain current speed If distance deviation is negative and distance is less than 2 cars length, –Slow down If distance deviation is positive and distance is greater than 2 cars length, –Speed up
23
GATE-561 23 Complete Rule Table Distance Distance Deviation Shrinking Fast ShrinkingStableGrowingGrowing Fast Very smallBrake hard Slow down Maintain speed SmallBrake hardSlow down Maintain speed Speed up Normal (2 cars length) Slow down Maintain speed Speed up LargeSlow downMaintain speed Speed up Floor it Very largeMaintain speed Speed up Floor it
24
GATE-561 24 Definition of Distance DistanceFuzzy set Very smallLess than 1 car length SmallAbout 1 car length NormalAbout 2 cars length LargeAbout 3 cars length Very largeMore than 3 cars length
25
GATE-561 25 Definition of Distance DistanceFuzzy set Very smallLess than 1 car length SmallAbout 1 car length NormalAbout 2 cars length LargeAbout 3 cars length Very largeMore than 3 cars length 1 2xl2xl 1xl1xl Normal distance 3xl3xl SmallLarge Very Small Very Large 0
26
GATE-561 26 Definition of Distance Deviation Distance DeviationFuzzy set Shrinking fastHigh negative ShrinkingLess than zero StableAbout zero GrowingGreater than zero Growing fastHigh positive
27
GATE-561 27 Definition of Distance Deviation Distance DeviationFuzzy set Shrinking fastHigh negative (half of car’s speed less) ShrinkingLess than zero StableAbout zero GrowingGreater than zero Growing fastHigh positive (half of car’s speed more) 1 0-1/2 x s Stable distance deviation 1/2 x s ShrinkingGrowing Shrinking Fast Growing Fast 0
28
GATE-561 28 Definition of Action ActionFuzzy set Brake hardSpeed = Speed/2 Slow downSpeed = Speed*2/3 Maintain speedDo nothing Speed upSpeed = Speed*4/3 Floor itSpeed = Speed*2
29
GATE-561 29 Definition of Action ActionFuzzy set Brake hardSpeed = Speed/2 Slow downSpeed = Speed*2/3 Maintain speedDo nothing Speed upSpeed = Speed*4/3 Floor itSpeed = Speed*2 1 None1/2 x s Maintain Speed Action 2xs2xs Slow Down Speed Up Break Hard Floor it 0 4/3x s 2/3x s
30
GATE-561 30 Sample Values Distance = 1.4 m Distance Deviation = + 0.15 of current speed
31
GATE-561 31 Sample Values On Fuzzy Sets 1 2xl2xl 1xl1xl Normal distance 3xl3xl SmallLarge Very Small Very Large 1.4xl 0.25 0.12 1 0-0.5 x s Stable distance deviation 0.5 x s ShrinkingGrowing Shrinking Fast Growing Fast 0.15 0.6 0.1
32
GATE-561 32 Matching Rules Distance Distance Deviation Shrinking Fast ShrinkingStableGrowingGrowing Fast Very smallBrake hard Slow down Maintain speed SmallBrake hardSlow downSlow down (0.1) Maintain speed (0.25) Speed up Normal (2 cars length) Slow down Maintain speed (0.1) Speed up (0.12) Speed up LargeSlow downMaintain speed Speed up Floor it Very largeMaintain speed Speed up Floor it 0.10.6 0.12 0.25 degree of trueness = min of both
33
GATE-561 33 Defuzzification of Matching Rules There are many available defuzzification methods Center of mass calculation on the fuzzy set areas can be used 1 1/2 x s Maintain Speed action 2xs2xs Slow Down Speed Up Break Hard Floor it 0 %25 = max(0.25, 0.1)%10%12 Center-of-mass 1.1 x speed
34
GATE-561 34 Fuzzy Logic Usage Can be used in many applications that requires to emulate a human expert
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.