Lecture 10 Introduction to NPC Behaviours - PowerPoint PPT Presentation

1 / 42
About This Presentation
Title:

Lecture 10 Introduction to NPC Behaviours

Description:

... the original formula is valid (also a formula is always true, it is a tautology) ... Which expression is a Tautology, Satisfiable, Insatisfiable. ... – PowerPoint PPT presentation

Number of Views:50
Avg rating:3.0/5.0
Slides: 43
Provided by: abdennour8
Category:

less

Transcript and Presenter's Notes

Title: Lecture 10 Introduction to NPC Behaviours


1
Lecture 10Introduction to NPC Behaviours
Production Systems(aka Rule-Based Systems)Dr
Abdennour El Rhalibi
2
Objectives
  • To understand the notion of production and
    rule-based systems
  • To be able to specify sets of rules for the
    behaviour of a character
  • To be be aware of design issues

3
Artificial Intelligence
  • Artificial Intelligence (AI) is a term that
    encompasses many definitions
  • Most Experts agree that AI is concerned with two
    basic ideas
  • It involves studying the thought processes of
    humans
  • It deals with representing those processes via
    machines (computers, robots, and so on)

4
Conventional vs AI Computing
5
Knowledge and AI
  • AI is frequently associated with the concept of
    knowledge
  • Computers cannot (as yet) have experiences, study
    or learn as the human mind can
  • But it can use knowledge given to it by human
    experts
  • Such knowledge consists of facts, concepts,
    theories, heuristics, procedures, and
    relationships
  • The collection of knowledge related to a problem
    is organized and stored in a knowledge base

6
Knowledge Representation
  • How do we explicitly represent our knowledge
    about the world?
  • Logical languages are analogous to programming
    languages
  • systems for describing knowledge that have a
    rigid syntax (Formal)
  • Logical languages (unlike programming languages)
    emphasize syntax.
  • In principle, the semantics is irrelevant (in a
    narrow sense) Symbolic Manipulation

7
Knowledge and reasoning
  • Objective to explicitly represent knowledge
    about the world
  • So that a computer can use it efficiently.
  • Simply to use the facts we have encoded
  • To make inferences about things it doesnt know
    yet
  • So that we can easily enter facts and modify our
    knowledge base
  • The combination of a formal language and a
    reasoning mechanism is a logic
  • Each fact is encoded as a sentence

8
Wffs Propositional Logic
  • In practice, with logical languages we combine
    symbols to express truths, or relationships,
    about the world.
  • If we put the symbols together in a permitted
    way, we get a well-formed formula or wff.
  • A proposition is another term for an allowed
    formula.
  • A propositional variable is a proposition that is
    atomic thats it, it cannot be subdivided into
    other (smaller) propositions
  • A propositional variable takes its value from
    true, false
  • Examples the following assertions are
    propositional variables
  • p, q, s, t a set of variables
  • father(john, jim)
  • duck_is_a_bird
  • light_on / light_off
  • platypus_is_a_bird

9
Wffs Propositional Logic
  • We can combine propositional variables into
    compound statements (wffs) using truth-functional
    connectives
  • AND (? ), OR (? ), NOT (?), IMPLIES (?),
    EQUIVALENCE (?)
  • Formulae are made from propositional variables
    and the Connectives
  • Examples
  • a ? b
  • platypus_is_a_bird ? platypus_is_a_mammal
  • man(jim) ? human(jim)
  • ? (A? (B ? A))

10
Terminology
  • A set of wffs connected by AND's is a
    conjunction.
  • A set of wffs connected by OR's is a disjunction.
  • Literals plain propositional variables, or their
    negations P and P.
  • Semantics We attach meaning to wffs in 2 steps
  • 1. By assigning truth values to the propositional
    variables
  • 2. By associating real-world concepts with
    symbols
  • Step 1, assigning truth values, is called an
    interpretation.
  • Step 2, is called symbol grounding.

11
Interpretation
  • Exercise Calculate using truth table and truth
    tree the value of
  • ((q ? p) ?(q ? ? p))

12
Models
  • A particular set of truth assignments associated
    with propositional variables is a model IF THE
    ASSOCIATED FORMULA (or formulae) come out with
    the value true.
  • e.g. For the formula (A and B) implies ( C and D)
  • the assignment
  • Atrue Btrue Ctrue Dtrue
  • is a model.
  • The assignment
  • Afalse Btrue Ctrue Dtrue
  • is another model, but the assignment
  • Atrue Btrue Ctrue Dfalse
  • is not a model.

13
Satisfiability
  • If no model is possible for a formula, then
    the
  • formula is NOT SATISFIABLE, otherwise it is
    satisfiable.
  • A Theory is a set of formulae (in the context of
    propositional logic).
  • If no model is possible for the negation of a
    formula, then we say the original formula is
    valid (also a formula is always true, it is a
    tautology).
  • An axiom is a wff that states a priori
    information.
  • Proper axioms state facts.

14
Tutorial Exercises
  • I) Propositional Logic
  • (i)                 (?A ? ?B) ? (B ? A)
  • (ii)               (A ? B) ? (?A ? B)
  • (iii)             ? (A? (B ? A))
  • (iv)             (A? (B ?C)) ? ((A ? C) ? (A ?
    B))
  • (v)               ((A ? B ) ? (B ? C)) ? (? ((A ?
    B) ? C) ? ((A ? B ) ? B))
  •  
  • Determine the models (interpretation of the
    variables for which the expression is true) for
    these three wffs. Which expression is a
    Tautology, Satisfiable, Insatisfiable.
  • Use a truth table for (i) (ii)and truth tree for
    (ii), (iii) and (iv).

15
Discovering new truths
  • Want to be able to generate new sentences that
    must
  • be true, given the facts in the KB.
  • Generation of new true sentences from the KB is
    called entailment.
  • We do this with an inference procedure.
  • If the inference procedure works right we only
    get entailed sentences. Then the procedure is
    sound or truth-preserving.

16
Rules of Inference
  • Modus (Ponendo) Ponens - MP
  • P ? Q, P ((P ? Q) ? P) ? Q
  • Q
  • Modus (Tollendo) Tollens - MT
  • P ? Q, ? Q ((P ? Q) ? ? Q) ? ? P
  • ? P

17
Introduction to production systems (1)
  • Production systems are sets of rules, which take
    a general IF-THEN form
  • Example
  • IF (shield is low) THEN (avoid mines) -- Wipeout

Left-hand side CONDITION
Right-hand side ACTION
NB The right hand side can consist of Action OR
Facts
18
Introduction to production systems (2)
  • The elements of rules are facts
  • (Health gt 90)
  • (You_have_the_plasma_gun)
  • etc.
  • Facts are matched to the systems status, e.g. to
    determine if (Health gt 90) holds, you must
    compute health, etc.
  • Abstract facts (situation_is_bad) are often
    themselves produced by rules

19
Elements of a production system
  • Facts
  • Rules
  • Inference Engine
  • Control Mechanism

20
Facts and expressions
  • if a typical rule is
  • IF facts THEN more facts actions
  • There is a need to define the expressions for
    facts, i.e. facts related through and/or
    connectors
  • Expressions are formulas of facts
  • (health gt 90) and (armour gt 90) and (ammo gt 50)
  • (number_of_enemies lt 5) or (got_LG9000)

21
Facts
  • Facts are elementary situations that you can
    access from the game
  • They can be concrete or more abstract
  • concrete (ammo gt 50)
  • abstract situation_is_good
  • Abstract facts are generally derived from
    concrete facts by the application of rules

22
Facts
  • remaining_ammo
  • health_status
  • distance_to_goal
  • number_of_keys
  • position(x, y, z)
  • Simple facts can be part of your internal status
    representation
  • Complex facts are aggregates of simple facts

23
Rules (1)
  • How do rules relate to the real world

IF facts THEN facts
abstract facts
Concrete facts
IF facts THEN action
on the world
24
Rules (2)
  • The effect of some rules is to add new facts that
    will trigger other rules
  • IF (health lt 50) and (armour lt 10)
  • THEN (Situation_is_bad)
  • The effect of other rules is to trigger action
  • IF (health lt 10) and (Medikit nearby)
  • THEN (pick up the Medikit at once)

25
Rules (3)
  • The IF-THEN formalism is powerful, but also
    ambiguous if you are not careful
  • IF-THEN rules can mean very different things
  • Eventually you have to check that the
    representation is meaningful in terms of
    application semantics

26
Production Rules
  • A Production rule specifies the relationship
    between facts
  • A production rule is composed of a Left Hand Side
    (LHS) and a Right Hand Side, connected by an
    implication (?)
  • LHS ? RHS
  • LHS and RHS are conjunctions
  • LHS conjunctions of conditions e.g. A ? ? B ?
    C ?D
  • RHS conjunction of conclusions e.g. B ?F
  • A ? ? B ? C ?D ? B ?F
  • Interpretation if A and not(B) and C and D then
    B and F

27
Rules of Inference Application
AB
  • Example KBS Production Rules
  • A, B initial list of facts
  • G Goal
  • A ? C (rule R1)
  • B ? C ? D (rule R2)
  • D ? A ? F ? ? A (rule R3)
  • D ? B ? F ? ? B (rule R4)
  • F ? G (rule R5)
  • Principle
  • Selection
  • Conflict Resolution
  • Rule Choice

R1
ABC
R2
ABCD
R4
R3
BCDF
ACDF
R5
Modus Ponens Forward Chaining Data Directed
Search Saturation
BCDFG
?
ACDFG
?
28
Rules of Inference Application
G
  • Example KBS Production Rules
  • A, B initial list of facts
  • G Goal
  • A ? C (rule R1)
  • B ? C ? D (rule R2)
  • D ? A ? F ? ? A (rule R3)
  • D ? B ? F ? ? B (rule R4)
  • F ? G (rule R5)
  • Principle
  • Selection
  • Conflict Resolution
  • Rule Choice

R5
F
R4
R3
DA
DB
R2
ABC
R2
?
BC
Modus Tollens Backward Chaining Goal Directed
Search
R1
BC
?
29
Predicate Calculus
  • Also known as first order logic
  • A formal system with a world made up of
  • Objects
  • Properties of objects
  • Relations between objects.
  • Adds quantification over objects to propositional
    logic.
  • " x passes_final(x) Þ gets_credit(x)
  • x passes_final(x) Þ gets_credit(x)

30
Predicate Calculus
  • Exampleancestor Relation with Propositional
    Logic
  • Facts
  • ancestor(jean, paul), ancestor(paul,jim),ancestor(
    jim, bob)
  • Goals
  • ancestor(jean, bob) Only Specific Questions?
  • Rules as much rules as combination of facts
  • ancestor(jean,paul) Ù ancestor(paul,jim) ?
    ancestor(jean,jim) (R1)
  • ancestor(paul,jim) Ù ancestor(jim,bob) ?
    ancestor(paul,bob) (R2)
  • . (Rn)
  • Exampleancestor Relation with Predicates Logic
  • Facts
  • ancestor(jean, paul), ancestor(paul,jim),
    ancestor(jim, bob)
  • Goals
  • ancestor(jean, bob) Specific Questions?
  • Ancestor(x,y) General Question?
  • Rule 1 rule to express the relation
  • ancestor(x,y) Ù ancestor(y,z) ? ancestor(x,z)
    (R1)

31
Predicate Calculus
Forward Chaining
ancestor(jean, paul), ancestor(paul,jim), ancesto
r(jim, bob)
ancestor(jean, paul), ancestor(paul,jim), ancesto
r(jim, bob), ancestor(jean,jim)
R1 xpaul,yjim,zbob
R1 xjean,ypaul,zjim
ancestor(jean, paul), ancestor(paul,jim), ancesto
r(jim, bob), ancestor(paul,bob)
R1 xpaul,yjim,zbob
ancestor(jean, paul), ancestor(paul,jim), ancesto
r(jim, bob), ancestor(jean,jim), ancestor(paul,bob
)
ancestor(jean, paul), ancestor(paul,jim), ancesto
r(jim, bob), ancestor(jean,jim), ancestor(paul,bob
) ancestor (jean,bob)
  • Principle
  • Pattern Matching
  • Conflict Resolution
  • Rule Choice

R1 xjean,yjim,zbob
?
See Example Tutorial 2 Stud Farm Knowledge Based
System
32
Facts Rules Pattern Matching
  • Pattern Matching is the process by which the
    left-hand side of a rule (condition) is matched
    to the current facts
  • When expressions are simple, it is just a matter
    of determining
  • whether all facts hold (AND rules)
  • whether any of the facts holds (OR rules)
  • (we do not consider logical expressions, and
    negation has a special status)

33
Forward chaining
IF (health lt 40) THEN (health_is_bad)
IF (health_is_bad) and (no plasma_gun) THEN
(situation_is_bad)
  • Forward chaining is the simplest way to apply
    production systems

34
Backward chaining ()
  • Backward chaining is used to demonstrate that a
    conclusion is true, going from that conclusion
    back to the facts

IF A and B THEN C
prove G
IF C or D THEN E
IF E and F THEN G
look for A and B Either in the facts list Or
obtained from other rules
look for F Either in the facts list Or obtained
from other rules
35
Inference Engine
  • The Inference Engine is a procedure or algorithm
    that decides how to trigger the rules in order to
    produce new facts (forward chaining) or
    demonstrate the validity of some facts (backwards
    chaining)
  • RETE Algorithms CLIPS, JESS

36
Meta-Rules ()
  • Meta-rules are rules which operate on rules
  • They are used in conflict resolution, where
    several rules can be applied
  • IF (several rules can be applied)
  • THEN (apply first rules dealing with health)

37
Weighting Rules
  • It is possible to attach confidence scores or
    salience to rules
  • These can be used to select rules from the
    conflict set

38
Examples of Rules
  • IF (youre unarmed) and (weapon in LoS)
  • THEN (go for the weapon)
  • IF (youre unarmed) and (no weapon in LoS) and
    (sergeant nearby)
  • THEN (kill sergeant and get his shotgun)
  • IF (youre unarmed) and (no weapon in LoS) and
  • (no sergeant nearby)
  • THEN (progress unarmed)

39
Exploratory Programming
  • Rule-based programming is exploratory
  • get a set of rules
  • run the system and explore behaviours
  • change a few rules to adapt behaviour
  • run the system again
  • etc.
  • This is possible because of the declarative
    nature of the rule-based representations

40
Tutorial Solutions
41
Tutorial Solutions
42
Tutorial Solutions
Write a Comment
User Comments (0)
About PowerShow.com