Top Banner
Fuzzy Logic By Andrew Pro
28

Fuzzy Logic By Andrew Pro. References Alexander, Thor, “An Optimized Fuzzy Logic Architecture For Decision Making”, AI Game Wisdom. Bonissone, P. Piero.

Dec 19, 2015

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Fuzzy Logic By Andrew Pro. References Alexander, Thor, “An Optimized Fuzzy Logic Architecture For Decision Making”, AI Game Wisdom. Bonissone, P. Piero.

Fuzzy Logic

By Andrew Pro

Page 2: Fuzzy Logic By Andrew Pro. References Alexander, Thor, “An Optimized Fuzzy Logic Architecture For Decision Making”, AI Game Wisdom. Bonissone, P. Piero.

References• Alexander, Thor, “An Optimized Fuzzy Logic Architecture For Decision Making”, AI

Game Wisdom.• Bonissone, P. Piero and Cheetham, William, “Fuzzy Case Based Reasoning For

Residential Property Valuation” (http://www.rpi.edu/~bonisp/fuzzy-course/99/L10/fuzzycbr4realestate.pdf)

• Hansen, Bjarne K., and Riordan, Denis, “Weather Prediction Using Case-Based Reasoning and Fuzzy Set Theory” (http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.16.3814)

• Hellman, M., “Fuzzy Logic Introduction” (http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.85.9757&rep=rep1&type=pdf)

• Shwab, Brian, AI Game Engine Programming. (http://site.ebrary.com/lib/lehighlibrary/docDetail.action?docID=10074871&force=1)

• Zarozinski, Michael, “Imploding Combinatorial Explosion In A Fuzzy System”, Game Programming Gems 2.

• http://www.doc.ic.ac.uk/~nd/surprise_96/journal/vol4/sbaa/report.html

Page 3: Fuzzy Logic By Andrew Pro. References Alexander, Thor, “An Optimized Fuzzy Logic Architecture For Decision Making”, AI Game Wisdom. Bonissone, P. Piero.

Outline• Introduction to Fuzzy Logic

• Fuzzy Game AI

• Fuzzy Logic in CBR

Page 4: Fuzzy Logic By Andrew Pro. References Alexander, Thor, “An Optimized Fuzzy Logic Architecture For Decision Making”, AI Game Wisdom. Bonissone, P. Piero.

Introducing Fuzzy Logic

• Takes into account the approximate nature of human reasoning– If the light is turned off, the room will be dark.

How dark?

• Everything in Fuzzy logic is a matter of degree – Binary logic is fixed at a degree of 0 or 1, where

fuzzy truth values can be anywhere in the range of [0,1]

Page 5: Fuzzy Logic By Andrew Pro. References Alexander, Thor, “An Optimized Fuzzy Logic Architecture For Decision Making”, AI Game Wisdom. Bonissone, P. Piero.

Paradox of Self-Reference (just for fun)

• Liar paradox – “This sentence is false.”– In binary logic, X cannot equal ¬X.– We can use fuzzy logic and declare X to be (.5)

false, so ¬((.5)X) = (.5)X. “This sentence is (half) false.” is (half) true.

• Epimenedes – A Cretan says: “All Cretans are liars.”– Perhaps he means with a truth value of .999

Page 6: Fuzzy Logic By Andrew Pro. References Alexander, Thor, “An Optimized Fuzzy Logic Architecture For Decision Making”, AI Game Wisdom. Bonissone, P. Piero.

Fuzzy Membership Functions

• Fuzzy Logic extends multi-valued logic• A function is defined for each logic value• Instead of values being mutually exclusive like

in a normal logic system, the logic values overlap .

Page 7: Fuzzy Logic By Andrew Pro. References Alexander, Thor, “An Optimized Fuzzy Logic Architecture For Decision Making”, AI Game Wisdom. Bonissone, P. Piero.

Fuzzy Membership Functions• Functions can be simple or complex (fuzzily

speaking of course)• Which functions could describe the fuzzy

value, Tall?

Page 8: Fuzzy Logic By Andrew Pro. References Alexander, Thor, “An Optimized Fuzzy Logic Architecture For Decision Making”, AI Game Wisdom. Bonissone, P. Piero.

Fuzzy Sets and Operations

• Fuzzy Set defined by function.– COLD(x) = 1 if temp(x)<= 50

(60 – temp(x))/10 if 50<temp(x)<600 if temp(x)>=60

– Negation ¬COLD(x) = 0 if temp(x)<= 50

(temp(x)-60)/10 if 50<temp(x)<601 if temp(x)>=60

• The function and its inverse overlap!

Page 9: Fuzzy Logic By Andrew Pro. References Alexander, Thor, “An Optimized Fuzzy Logic Architecture For Decision Making”, AI Game Wisdom. Bonissone, P. Piero.

Fuzzy Set Operation

• A AND Bat x=4.75

A AND B = min(A,B)= .25

• A OR Bat x=4.75

A AND B = max(A,B)= .75

Page 10: Fuzzy Logic By Andrew Pro. References Alexander, Thor, “An Optimized Fuzzy Logic Architecture For Decision Making”, AI Game Wisdom. Bonissone, P. Piero.

Fuzzy Logic or Probability Theory

• Fuzzy logic deals with the measure of how much a variable is in a particular set.

• Probability theory handles subjective probability where a function may map how likely a variable is to be in a particular set.

Page 11: Fuzzy Logic By Andrew Pro. References Alexander, Thor, “An Optimized Fuzzy Logic Architecture For Decision Making”, AI Game Wisdom. Bonissone, P. Piero.

Fuzzy Logic in Game AI

• Fuzzy logic can be used in a variety of ways to help game AI seem more human-like

• NPC Finite State Machines can be improved by making fuzzy determinations for state transition logic

Page 12: Fuzzy Logic By Andrew Pro. References Alexander, Thor, “An Optimized Fuzzy Logic Architecture For Decision Making”, AI Game Wisdom. Bonissone, P. Piero.

Example NPC FSM• Character stays in state until distance value is crossed

Page 13: Fuzzy Logic By Andrew Pro. References Alexander, Thor, “An Optimized Fuzzy Logic Architecture For Decision Making”, AI Game Wisdom. Bonissone, P. Piero.

FSM Rules

• FSM transition rules: State Chase– IF player is close THEN attack– ELSE IF player is far THEN returnHome– ELSE chase

• Close and far are crisply defined– Is necessary if distance is the only state transition

measure

Page 14: Fuzzy Logic By Andrew Pro. References Alexander, Thor, “An Optimized Fuzzy Logic Architecture For Decision Making”, AI Game Wisdom. Bonissone, P. Piero.

Fuzzy Rules cont’d

• Fuzzy rules might be– IF player is close THEN attack– IF player is far THEN returnHome– IF player is inbetween THEN chase

• Combined with other factors (weapon range, time of day, weather condition) a distance measured close may not be close enough

• The NPC now has more varied, interesting behavior

Page 15: Fuzzy Logic By Andrew Pro. References Alexander, Thor, “An Optimized Fuzzy Logic Architecture For Decision Making”, AI Game Wisdom. Bonissone, P. Piero.

Fuzzy AI Decision• Rules are created using

every combination of 1 set from each variable.

• Rules may be difficult to produce. Variables can be given weights or rule base can be generated by expert.

Page 16: Fuzzy Logic By Andrew Pro. References Alexander, Thor, “An Optimized Fuzzy Logic Architecture For Decision Making”, AI Game Wisdom. Bonissone, P. Piero.

Fuzzy AI Decision cont’d

• Each rule has an aggressiveness value (or truth value) using the Fuzzy AND operation.

• All-out attack is the best choice because is has the highest degree of truth, but there still is a small part of Fight defensively that wants to be considered. So…

Page 17: Fuzzy Logic By Andrew Pro. References Alexander, Thor, “An Optimized Fuzzy Logic Architecture For Decision Making”, AI Game Wisdom. Bonissone, P. Piero.

Defuzzification• Want to derive a numeric output value for

aggressiveness. One method is the center-of-mass method

• Take the maximum value from each output variable set. (attack – 53, defend – 18, run – 0)

• Create a full output block by capping each membership function at the final output value, then OR the functions.

• Find the center of mass.

Page 18: Fuzzy Logic By Andrew Pro. References Alexander, Thor, “An Optimized Fuzzy Logic Architecture For Decision Making”, AI Game Wisdom. Bonissone, P. Piero.

Combinatorial Explosion

• For real time AI, this becomes unpractical at a certain point.

• Can compromise some of the functionality to significantly reduce the number of rules.

Page 19: Fuzzy Logic By Andrew Pro. References Alexander, Thor, “An Optimized Fuzzy Logic Architecture For Decision Making”, AI Game Wisdom. Bonissone, P. Piero.

The Combs Method

• Use rules based on each set’s relationship to the output.

• Take output from each rule fired, OR the matching sets to get the overall truth value for each output set.– (Run – 0, Defense – 83, Attack – 60)

• Different, but still reasonable– Aggressiveness values fairly close after

defuzzification

Page 20: Fuzzy Logic By Andrew Pro. References Alexander, Thor, “An Optimized Fuzzy Logic Architecture For Decision Making”, AI Game Wisdom. Bonissone, P. Piero.

Fuzzy AI

• Keep fuzziness in game AI on a small scale

• FuSM can be used where states don’t interfere with eachother.– Face modeling can be fuzzy to look more natural

Page 21: Fuzzy Logic By Andrew Pro. References Alexander, Thor, “An Optimized Fuzzy Logic Architecture For Decision Making”, AI Game Wisdom. Bonissone, P. Piero.

Fuzzy CBR

• Think about CBR using fuzzy logic– Case is similar or not similar

– Retrieval can be more accurate with fuzzy attributes (…symbolic attributes)

– Case can be adapted using fuzzy set functions based on differences between problem case and retrieved case

Page 22: Fuzzy Logic By Andrew Pro. References Alexander, Thor, “An Optimized Fuzzy Logic Architecture For Decision Making”, AI Game Wisdom. Bonissone, P. Piero.

Restaurant ExampleEx’ple Bar Fri Hun Pat Alt Type wait x1 no no yes some yes French yes

x4 no yes yes full yes Thai yes

x5 no yes no full yes French no

x6 yes no yes some no Italian yes

x7 yes no no none no Burger no

x8 no no yes some no Thai yes

x9 yes yes no full no Burger no

x10 yes yes yes full yes Italian no

x11 no No no none no Thai no

Page 23: Fuzzy Logic By Andrew Pro. References Alexander, Thor, “An Optimized Fuzzy Logic Architecture For Decision Making”, AI Game Wisdom. Bonissone, P. Piero.

Restaurant Example

• Bar / No Bar doesn’t really work, but fuzzifying Hungry and Patrons could help– (starving, pretty hungry, a little hungry)

• Patrons seems to be begging for fuzziness.– Is the difference between None and Some really

just 1 patron?– Does full actually mean there are no open tables

whatsoever?

Page 24: Fuzzy Logic By Andrew Pro. References Alexander, Thor, “An Optimized Fuzzy Logic Architecture For Decision Making”, AI Game Wisdom. Bonissone, P. Piero.

Fuzzy CBR Systems• WIND-1– Weather prediction for airports. Expert identifies

fuzzy attributes (cloud ceiling, visibility, etc)

– Expert defines similarity thresholds to measure sim between cases. Outputs are fuzzy. (Very near, near, slightly near)

– Fuzzy predictor performs more accurately than system finding k-NN using crisp attribute values.

Page 25: Fuzzy Logic By Andrew Pro. References Alexander, Thor, “An Optimized Fuzzy Logic Architecture For Decision Making”, AI Game Wisdom. Bonissone, P. Piero.

Fuzzy CBR Systems

• PROFIT– Fuzzy CBR system for real estate value estimation

that uses fuzzy logic in similarity computation, case adaptation, and confidence value generation

– Sale comparison approach: “finding the most similar houses, located close to the subject property, sold not too long ago; and selecting a balanced subset of the most promising comparables to derive the final estimate.”

Page 26: Fuzzy Logic By Andrew Pro. References Alexander, Thor, “An Optimized Fuzzy Logic Architecture For Decision Making”, AI Game Wisdom. Bonissone, P. Piero.

Fuzzy CBR Systems cont’d (PROFIT)• Similarity functions describing living area, lot

size, preferred #bedrooms, and preferred #bathrooms

Page 27: Fuzzy Logic By Andrew Pro. References Alexander, Thor, “An Optimized Fuzzy Logic Architecture For Decision Making”, AI Game Wisdom. Bonissone, P. Piero.

Fuzzy CBR Systems cont’d (PROFIT)

• Finds most similar cases, applies adjustment rule set using differences to subject case. Similarity rank could differ from net adjustment rank. Discard cases with too much price adjustment. Final estimate = sum(adjPrice*sim)/sum(sim)

• Confidence assessment using aggregation of fuzzy functions related to cases retrieved, similarity, average price adjustment, etc.

Page 28: Fuzzy Logic By Andrew Pro. References Alexander, Thor, “An Optimized Fuzzy Logic Architecture For Decision Making”, AI Game Wisdom. Bonissone, P. Piero.

Conclusion• Fuzzy logic helps represent vague variables

and sets in a more natural

• Game AI can be altered using fuzzy state transitions and/or fuzzy states to add variance to NPCs

• In Case-Based Reasoning, the Retrieve and Revise steps can benefit from having fuzzy membership functions of case features.