Fuzzy Logic - PowerPoint PPT Presentation

1 / 57
About This Presentation
Title:

Fuzzy Logic

Description:

Fuzzy Logic CIS 488/588 Bruce R. Maxim UM-Dearborn World Objects Items Direct effect on player state (e.g. health or armor) No direct effect on player state (e.g ... – PowerPoint PPT presentation

Number of Views:161
Avg rating:3.0/5.0
Slides: 58
Provided by: BruceM153
Category:
Tags: armor | body | fuzzy | logic

less

Transcript and Presenter's Notes

Title: Fuzzy Logic


1
Fuzzy Logic
  • CIS 488/588
  • Bruce R. Maxim
  • UM-Dearborn

2
World Objects
  • Items
  • Direct effect on player state (e.g. health or
    armor)
  • No direct effect on player state (e.g.
    invincibility)
  • Strategies to maximize benefits of object
    collection are important for game bots to appear
    smart
  • Contraptions (puzzles)
  • Generally designed to slow down escape or impede
    access to weapons (e.g. ladder or switch)
  • A sequence of player actions must precede their
    use

3
Test Bed
  • Fairly easy to test object collection strategies
    (most game levels have lots of items)
  • Presence of contraptions is relatively rare since
    these elements are often architecture
    centerpieces, so it is harder to test animat
    abilities to use them without creating simplified
    custom levels for training

4
Human Behavior - 1
  • Picking up Items
  • Picking up objects in many games is simply a
    matter of walking over them
  • Unlike obstacle avoidance that can be done while
    wondering, picking up objects requires
    intentional movement to be efficient
  • Handling Contraptions
  • Must combine specific skills (button pressing or
    waiting) with movement
  • Sequences of actions (plans) are often required
    to solve the puzzle of operation

5
Human Behavior - 2
  • Behavior Enhancers
  • Special skills that improve game play (e.g.
    dodging projectiles or jumping)
  • Just like using contraptions these actions may
    require development of a sequence of actions
    (plan) and preconditions (e.g. location or
    timing) for its use

6
Criteria
  • To maintain illusion of realism the AI cannot be
    too good at using items or solving puzzles
  • Even if the AI is realistic do not over use it
  • Effectiveness
  • Make the behavior as efficient as possible (no
    wasteful moves or pauses)
  • Consistency
  • AI actions must be justifiable (follow up actions
    are taken)

7
Behavior Case Study - 1
  • Opening door
  • NPC walks toward switch
  • Pushes switch on contact
  • NPC stands back while door opens
  • NPC goes through door
  • Getting onto platform
  • NPC press switch
  • Waits for platform to arrive
  • Gets on platform and it moves

8
Behavior Case Study - 2
  • Getting on ladder
  • NPC moves till contact made
  • NPC must face ladder to avoid falling off
  • Climbing done by looking up and moving forward
  • Jump Pads
  • NPC needs to walk on pad
  • NPC tossed in the air
  • Moving while in the air controls the fall

9
Behavior Case Study - 3
  • Dodging
  • Move away from line of fire for incoming
    projectiles and their predicted point of impact
  • Rocket Jumping
  • NPC needs to look down
  • Jump using standard command
  • Shoot a rocket at the ground

10
Interfaces - 1
  • New movement functions (can be used in
    combination with movement)
  • void Jump( )
  • void Duck( )
  • New inventory functions
  • void ItemsAvailable(vectorltEntitygt items,
  • const EntityType unifier 0)
  • bool UseItem(Symbol item)

11
Interfaces - 2
  • Vision
  • No functional extensions needed only additional
    data past through it
  • AI will need to use of callback functions like
  • void OnDoorOpen(const Event event)
  • Physical State (collection of queries)
  • bool isPlatform( )
  • bool isLadder( )
  • bool isWater( )
  • bool isAir( )

12
Greedy
  • Attempts to collect every object in sight
  • Moves on only after every item is picked up or is
    inaccessible
  • Built on steering behaviors
  • (animat not in archive)

13
Fuzzy Set Theory
  • In ordinary set theory every element x from a
    given universe is either in or out of a set S
  • x ? S
  • x ? S
  • In fuzzy set theory set membership is not so
    easily determined

14
When is a pile of chalk big?
  • If we have three pieces of chalk in the room is
    that considered a big pile of chalk?
  • Some people might say, yes that is a big pile and
    some would not.
  • Someplace between those three pieces of chalk and
    a whole room full of chalk the pile of chalk
    turns from a small pile into a big pile.
  • This could be a different spot for different
    people.

15
Membership Function
  • ?A X ? 0,1
  • x ? ?A(x) ? x ? X
  • X is universe of discourse
  • x ? X
  • ?A(x)
  • x ? X
  • 1/x

16
Fuzzy Set
  • Collection of ordered pairs (x, ?A(x)) known as a
    fuzzy singleton
  • Consider a set A defined as the set of hostile
    game objects from X
  • X door, gun, fred, bot1
  • a 0 0 0.3 0.8
  • A (door,0), (gun,0), (fred, 0.3), (bot1,
    0.8)

17
?x A(x) lt B(x)
18
Fuzzy Modifiers - 1
  • In very dangerous the word very could be
    thought of as a fuzzy linguistic modifier
  • dangerous 0 0.1 0.4 0.8 1
  • very dangerous 0 0.01 0.16 0.64 1
  • More formally we could think of a fuzzy modifier
    m as a function that converts one fuzzy set a
    into another set m(a)
  • m X ? F(X)
  • a ? m(a) ? a ? F(X)

19
Fuzzy Modifiers - 2
  • Possible fuzzy definitions
  • very(a) a2
  • extremely(a) a3
  • moreorless(a) a1/2
  • slightly(a) a1/3
  • exactly(a) a?
  • always(a) a0
  • Adverbs might be used as offset modifiers
  • A(x) m(A(x k))

20
Fuzzy Variables and Values
  • Fuzzy variables can be considered as a term
    associated with a floating point value
  • A collection of fuzzy variables could be used to
    define an enemy profile
  • (healthy 0.9) (dangerous 0.3) (moving 0.3)
  • Linguistic variables is a collection of fuzzy
    variables used to de

21
Liguistic Variables
  • Linguistic variables is a collection of fuzzy
    variables used to define a high level concept
    like allegiance
  • term set enemy,neutral,friendly
  • values 0.0, 0.4, 0.9
  • A linguistic variable is defined over a base
    variable
  • Base variables can be either crisp or fuzzy values

22
(No Transcript)
23
Fuzzification
  • Creating a fuzzy variable from a crisp one
  • Define a membership function with the same range
    as the crisp variable
  • Evaluating the membership based on the crisp
    variable value indicates degree of set membership

24
(No Transcript)
25
Defuzzification - 1
  • Converts a fuzzy value to a crisp value
  • Fairly easy for fuzzy variables
  • Can be tricky for linguistic values
  • Process often involves information loss, unless
    you are doing simple conversions
  • There is no unique equation, since humans use
    problem-dependent techniques to defuzzify
    linguistic concepts

26
Defuzzification - 2
  • Maximum Approach
  • Uses highest points in membership function graph
  • First maxima picks crisp value from highest of
    all membership function
  • Average maxima weighted or unweighted average
    of all crisp values
  • Centroid Approach
  • based on finding center of gravity of the
    membership function graph
  • Very computationally intensive

27
(No Transcript)
28
Fuzzy Logical Operators
Operator Notation Equation
NOT ? 1 x
AND ? min(x, y)
OR ? max(x, y)
IMPLIES ? max(1 - x, y) max(0, x y 1)
29
Linguistic Expressions
  • Dead or alive
  • Extremely nasty and more or less dead
  • Shot and bleeding badly implies dying
  • d ? a
  • n3 ? d1/2
  • s ? b2 ? d

30
Fuzzy Logic
  • Fuzziness is really deterministic uncertainty and
    depends on probability assumptions which may not
    be met
  • Fuzzy logic contains inconsistencies
  • (e.g. the set of animats that are both dead and
    alive is not empty)
  • Seems to model human knowledge and reasoning
    better than standard truth functional logic

31
Fuzzy Control SystemsDecision Making
  • Working Memory
  • Similar to RBS, except fuzzy variables used in
    place of crisp symbols
  • Knowledge Base
  • Rules containing fuzzy variables are used
  • if very confident or somewhat vulnerable
  • then attack

32
Rule Extensions
  • Linguistic rules
  • Keyword is used to refer to fuzzy terms
  • if allegiance is friendly then happy
  • Fuzzy modifiers
  • Can be applied to both antecedent and consequent
    variables

33
Creating Membership Functions
  • Knowledge engineer can try to extract information
    and heuristics from human experts
  • Survey can be used to collect information
    regarding several peoples understanding and
    membership function reflects average
  • Incremental tuning will be required for any
    approach chosen

34
Fuzzy InterpreterMatching
  • In crisp systems it is easy to identify rules
    that match WM, facts are present or they are not
  • In fuzzy systems, fuzzy variables are rarely zero
    so every rule needs to be checked during every
    match cycle
  • To reduce impact of combinatorial explosion,
    thresholds will be used to reduce the number of
    low probability matches

35
Fuzzy InterpreterInference
  • Purpose is to determine the degree of truth for
    the consequent part of each rule
  • Two techniques used
  • Min (uses the minimum of the rule antecedent
    values and treats this as the value for the
    output set possibilistic reasoning)
  • Products (uses the product of the rule antecedent
    values and treats this as the value for the
    output set probabilistic reasoning)

36
Fuzzy InterpreterComposition
  • Many rules have the same fuzzy variable in the
    rule body (consequent)
  • To combine support shown by multiple rules
  • Max (uses the maximum of the rule output values
    and uses this as the fuzzy variable value in WM
    possibilistic reasoning)
  • Sum (uses the sum of the rule output values and
    uses this as the fuzzy variable value in WM
    probabilistic reasoning)

37
Algorithm
  • // current WM with latest fuzzy variable values
  • // previous is copy of most recent WM
  • for each value in WM
  • previousvalue currentvalue
  • currentvalue 0
  • for each rule
  • result evaluate(rule.expression,previous)
  • currentrule/body max(currentrule.body,resul
    t)

38
Discussion 1
  • Fuzzy systems are surprisingly robust
  • Can cope with noisy and incomplete data
  • Requires little feedback to perform well
  • Fuzzy expert systems mimic human reasoning
    surprisingly well
  • Fuzzy RBS are easy to extend incrementally
  • Rule syntax is easy enough for non-programmers to
    write rules

39
Discussion 2
  • Fuzzy systems use rules of thumb (heuristics) and
    not mathematical models of the problem
  • Every rule needs to be evaluated during every
    match cycle which is computationally expensive
    (for a large number of rules)
  • Creating membership functions is not easy
  • Combinatorial explosion of rules is possible for
    large numbers of input combinations, unless
    knowledge is represented implicitly

40
Dominator
  • Uses fuzzy expert system to control movement and
    shooting
  • Uses fuzzy logic for weapon selection
  • Supposedly has the best performance of all
    animats
  • (not found in the current archive)

41
Actions - 1
  • Define linguistic variable move is defined with
    three values forwards, stop, backwards
  • forwards 1 if velocity is null and
  • 0 if velocity is full
  • backwards 0 if velocity is null and
  • 1 if velocity is full
  • stop not(forwards or backwards)
  • Fuzzy modifier extremely can be used to obtain
    steeper curve for stop

42
Actions - 2
  • Define base linguistic variable turn is defined
    as yaw turning angle (0 membership function means
    no turn)
  • Fuzzy terms as used to direct turn toward
    button, door, ladder, platform, exit
  • Linguistic variable look controls pitch
    separately
  • up pitch of 90
  • ahead pitch of 0

43
Senses - 1
  • Door is defined over opening height so value is 0
    when closed and 1 when open
  • Fully open door (degree of membership) DoM is
  • 1 if door can be walked through
  • 0 if crawl through is needed
  • Button_pressed is really a pure boolean singleton
    not fuzzy variable

44
Senses - 2
  • Platform is defined as two terms with DoM of 1
    when at starting point and 0 when player needs to
    double jump off
  • Term ready is distance off floor and how easy it
    is to climb on
  • Term arrived is distance to final location
  • Additional terms
  • aboard is 1 when on platform and 0 when not
    (peaks near (x,y) at platform center)

45
Senses - 3
  • Ladder is defined as two terms
  • Term held has DoM value of
  • 1 after 1 full second of touching
  • 0 when released for 1 full second
  • Term top has DoM defined over height and is
  • 1 when animat can step off
  • 0 when 1 step from the top

46
Rules for Using Doors - 1
  • if not button_pressed
  • then turn to button, move forward
  • if button_pressed then
  • then turn toward door
  • if button_pressed and door not fully open
  • then move stop
  • if door fully open
  • move forward, turn toward door

47
Rules for Using Doors - 2
  • Note these rules rely on the animat being
    interrupted once the doorway is crossed
  • A higher level AI needs to identify this case and
    stop calling the fuzzy behavior to prevent the
    animat from heading through the door (e.g. rule 1
    needs to be disabled by have the membership
    function of its action drop to zero once the
    button is pressed)

48
Rules for Using Ladders
  • True
  • then move forward
  • if ladder is not held
  • then turn toward ladder
  • if ladder is held
  • then look up
  • if ladder is top
  • then look ahead, turn toward exit

49
Rules for Using Platforms - 1
  • if not button_pressed
  • then turn to button, move forward
  • if button_pressed and platform not ready
  • then move stop
  • if button_pressed and not aboard
  • turn to platform
  • if platform is ready
  • then move forward

50
Rules for Using Platforms - 2
  • if aboard
  • then turn to exit
  • if aboard and platform has not arrived
  • then move stop
  • if aboard and platform has arrived
  • turn move forward
  • if platform is ready
  • then move forward

51
Working Memory - 1
  • Contains fuzzy terms used by interpreter
  • There is no difference in representation of
    individual and linguistic variables
  • Some terms will need to be associated with a
    membership function to fuzzifying or defuzzifying
  • Symmetric triangle is sufficient for the
    membership function

52
Working Memory - 2
  • ltmemorygt
  • ltVariable nameplatformgt
  • ltTerm nameready /gt
  • ltTerm namearrived /gt
  • lt/Variablegt
  • ltVariable namedoorgt
  • ltTerm nameopengt
  • lttriangle center0 base45 /gt
  • lt/Termgt
  • lt/Variable
  • lt/memorygt

53
Rulebase
  • ltrulebasegt
  • ltRulegt
  • ltconditionsgt
  • ltTerm nameaboard /gt
  • ltVariable nameplatform valuearrived /gt
  • lt/conditionsgt
  • ltbodygt
  • ltVariable namemove termforward
    value1 /gt
  • ltVariable nameturn termexit value1
    /gt
  • lt/bodygt
  • lt/Rulegt
  • lt/rulebasegt

54
Interface
  • Synchronization
  • void SetSensor(const SensorFunc s,
  • const string symbol)
  • void SetEffector(const EffectorFunc e,
  • const string symbol)
  • Dynamic Access
  • void Set(const string symbol,
  • const float value)
  • void Get(const string symbol)

55
Jacky
  • Uses fuzzy expert system
  • Can climb ladders, open doors, and call elevators
  • Default behavior is reactive wandering

56
Evaluation - 1
  • Fuzzy controlled movement is smooth except for
    button pressing
  • In some cases reaction times are a little slow
    (e.g. first rung of ladder or anticipating the
    arrival of platform)
  • Animat generally does not waste movement
  • Because fuzzy interpreter has direct control over
    movement animat can struggle to get past some
    obstacles

57
Evaluation - 2
  • Ideally fuzzy system output should be treated as
    a suggestion, rather than an order
  • Fuzzy interpreter does not keep track of which
    step in the sequence the animat is one (might
    need context variables like XCON/R1)
  • Might benefit from creating a fuzzy state machine
    rather than creating more complex rules
Write a Comment
User Comments (0)
About PowerShow.com