ARTIFICIAL INTELLIGENCE
Lecturer: Silja Renooij
Decision making: single agent
Utrecht University The Netherlands
These slides are part of the INFOB2KI Course Notes available from www.cs.uu.nl/docs/vakken/b2ki/schema.html
INFOB2KI 2019‐2020
ARTIFICIAL INTELLIGENCE Decision making: single agent Lecturer: - - PowerPoint PPT Presentation
Utrecht University INFOB2KI 20192020 The Netherlands ARTIFICIAL INTELLIGENCE Decision making: single agent Lecturer: Silja Renooij These slides are part of the INFOB2KI Course Notes available from www.cs.uu.nl/docs/vakken/b2ki/schema.html
Lecturer: Silja Renooij
Utrecht University The Netherlands
These slides are part of the INFOB2KI Course Notes available from www.cs.uu.nl/docs/vakken/b2ki/schema.html
INFOB2KI 2019‐2020
2
– Decision trees – Finite state machines – Behavior trees
When conditions are true/false and actions succeed (or not); decide on inputs, not desires/goals
3
Something which results in changes internal
e.g. Precondition: in(house,fire) Action: extinguishFire Postcondition: not in(house,fire)
4
Precondition: in(house1,fire) and close(I, house1) and has(I, fireHose) and capability(I, extinguishFire) and available(water) and not in(house1,victim) and safeable(house) Action: extinguishFire(house1) Postcondition: not in(house1,fire) and soaked(house1) and charred(house1)
5
– Instantaneous; not necessarily directly visible to player/user
– Instantaneous; not visible, only indirectly noticeable
(e.g, pathfinder)
– Duration, visible; might fail half way
6
– Action, strategy, goal, classification, …
– World state, belief about world state, cognitive state (of others),…
– Priorities for outcome, expiry time, achievement time,…
7
environments
priorities and behaviors
8
9
A B B
action1 action2 action3 action4 no yes no no yes yes
If‐then semantics: If A and B then action1 If A and not‐B then action2 If not‐A and B then action3 If not‐A and not‐B then action4 where A is short for “A=yes”, and not‐A is short for “A=no”…
10
Decision tree interpretation:
the path from root to the leaf are fulfilled
A B
action1 action2 action2 no yes no yes
A B
action1 action1 action2 no yes no yes
A B B
action1 action2 action2 action2 no yes no no yes yes
A B B
action1 action1 action1 action2 no yes no no yes yes
11
A B
action1 action2 action2 no yes no yes
A B
action1 action1 action2 no yes no yes
If A or (not‐A and B) then action1 If not‐A and not‐B then action2 Note that this is equivalent to: If A or B then action1 else action2
12
Interpretation in case multiple equivalent leaves:
the paths from root to the leaf are fulfilled
If A and B then action1 If not‐A or (A and not‐B) then action2 Note that this is equivalent to: If A and B then action1 else action2
A B C
action1 action2 action4 no yes no no yes yes
If‐then semantics: If A and B then action1 If (A and not B) or (not A and C) then action2 If not A and not C then action4
13
More compact representation when multiple equivalent leaves:
A
action1 action2 action3 action4 just fed starving hungry fed
Conditions can also concern non‐binary events.
14
Example: an ant’s life If‐then semantics: If A=starving then action1 If A=hungry then action2 If A=fed then action3 If A=just fed then action4
Under attack?
Random > n ? defend patrol rest no yes no yes
15
Example: an ant’s life
A B
Go(north) Go(north) Go(north,west) Go(north) no yes no no yes yes
A= food(north) B=food(west) or food(south) or food(east) C=food(south) D=food(west) or food(east) E=food(west) F=food(east) C
yes no
E
no no yes Go(south) Go(north,east)
D E
yes no yes
F
no yes Go(east) Go(west) Go(random)
F
no yes
Good model?
16
An ant in search of food….
A B
Go(north) Go(east) Go(west) Go(south) no yes no no yes yes
A=food_closest(north) B=food_closest(west) C=food_closest(south) D=food_closest(east)
C
17
Good:
condition
Bad:
have to be checked
18
19
– start in a state – perform the behavior of that state, if any (~ do action) – transition when the condition is true – until an end state is reached
State Machine.
20
terminal state ( ); action ‘wait for input’ in states
‘accepting’ the input seen What type of bit strings does this machine accept? (strings where the OR of all bits is True)
1 0 or 1 21
22
For woodcutter FSM see https://www.youtube.com/watch?v=FuvaehxklOA
On guard run fight See small enemy See big enemy escaped Loose fight
Example: an ant’s life
23
myState = OnGuard while myState == OnGuard: if see(small_enemy) : myState = Fight if see(big_enemy) : myState = Run guard() while myState == Fight: if loose() : myState = Run beat_enemy() while myState == Run: if escaped(): myState = OnGuard run_away() # current state # continue what you’re doing
24
On guard run fight See small enemy See big enemy escaped Loose fight Drink tea Drink tea Drink tea Tea finished Teatime Tea finished Tea finished Teatime Teatime
25
Not very efficient…
On guard run fight See small enemy See big enemy escaped Loose fight
Drink tea Tea finished Teatime
fighting
Top‐level transition:
recent state in ‘fighting’ FSM A (super) state can be a whole FSM: (=non‐`alarm’ level)
26
On guard run fight See small enemy See big enemy escaped Loose fight
Drink tea Tea finished Teatime
fighting
See no enemy
cross‐hierarchy transition
in ‘fighting’ FSM
27
On guard run fight enemy small See enemy escaped Loose fight yes yes no no
28
Find food run fight enemy alone See enemy no See more enemies yes yes no no Get caught die Loose fight yes
29
30
31
32
33
(choose first that is successful, then done; success if one sub‐task successful)
(bail out if fail; success only if all sub‐tasks successful)
34
live
Normal activity
danger ?
Find food Bring food to hive multiply
? run fight
35
character
next behavior is tried
through conditions
36
the rules explicitly
– Knowledge:
– Reasoning:
applicable, decides how to proceed
– Explanation facilities (not discussed)
37
Database with facts: health(captain,51) health(johnson,38) hold(whisker,radio) Rules: IF health(whisker,X) AND X<15 AND hold(whisker,radio) AND health(johnson,Y) AND Y>35 THEN pick_up(johnson,radio)
38
Use variables in rules to make them generally applicable unification (advanced wild‐card pattern matching) Rule: IF health(P1,X) AND X<15 AND hold(P1,radio) AND health(P2,Y) AND Y>35 THEN pick_up(P2,radio)
39
– IF enemy(X,Y) AND armed(Y,gun) AND distance(X,Y)<10 THEN in_danger(X) – IF enemy(X,Y) AND enemy(Z,Y) THEN friend(X,Z) – IF in_danger(X) AND NOT(friend(X,Z) AND distance(X,Z)<10 AND armed(Z,big‐gun)) THEN in_panic(X)
40
Reasoning rules
knowledge
knowledge ( database updates)
goal‐driven inference through backward chaining
41
Given a `goal’, find rules to achieve goal.
Question: friend(johnson,whisker) ? match this with consequent of a rule:
IF enemy(X,Y) AND enemy(Z,Y) THEN friend(X,Z)
recursively check if we can proof antecedent of rule:
enemy(johnson,Y) AND enemy(whisker,Y)
42
– IF enemy(X,Y) AND armed(X,gun) AND distance(X,Y)<10 THEN shoot(X,Y,gun) – IF in_panic(X) THEN run(X)
43
Action rules
condition true, the action part is executed
inference through forward chaining
44
antecedent (depending on forward/backward chaining)
But: when should which triggered rule be fired?
45
IF enemy(X,Y) AND armed(X,gun) AND distance(X,Y)<10 THEN shoot(X,Y,gun)
This rule will be triggered all the time when X is close to an
We need a mechanism to trigger a rule only once, or only as long as it is relevant
– IF enemy(X,Y) AND armed(X,gun) AND distance(X,Y)<10 AND NOT(dead(Y)) THEN shoot(X,Y,gun)
46
IF in_panic(X) THEN run(X)
After the rule is fired X starts running We check the rules again after the action (running) is finished might be a long time!
an action
47
Database with facts:
health(captain,51) health(whisker,5) health(johnson,38) hold(whisker,radio)
Rule: IF health(P1,X) AND X<15 AND hold(P1,radio) AND health(P2,Y) AND Y>35 THEN pick_up(P2,radio)
[P1=whisker, X=5, P2=johnson, Y=38]
48
– IF enemy(X,Y) AND armed(X,gun) AND distance(X,Y)<10 THEN shoot(X,Y,gun) – IF in_panic(X) THEN run(X)
enemy.
Should X run or shoot?
49
Decides which rule to fire when several are triggered. Possible mechanisms: 1.Order of rules: take first that triggers 2.(dynamic) Priorities (time consuming!) 3.Specificity: most specific condition 4.Recency: least recently used 5.…
50
Combine the conditions of the rules in a network and evaluate them all at once: Rete algorithm.
holds(P1,radio) health(P1)<15 health(P2)>35 covers(P2,P1) Pick-up radio rule Change backup rule
51
holds(P1,radio) health(P1)<15 health(P2)>35 covers(P2,P1) Pick-up radio rule Change backup rule
52
Bindings: P1=whisker Bindings: P1=whisker Bindings: P2=johnson P2=captain Bindings: P1=whisker P2=johnson P2=captain Bindings: P1=whisker P2=johnson P2=captain Bindings: P1=whisker P2=captain Bindings: P1=whisker P2=captain
– Corresponds to way people often think of knowledge – Very expressive – Modular knowledge
– Can be memory intensive – Can be computationally intensive – Sometimes difficult to debug (rules consistent?)
53