1 The Wumpus Game StenchBreeze Stench Gold Breeze StenchBreeze Start Breeze.
-
Upload
theresa-bryan -
Category
Documents
-
view
222 -
download
1
Transcript of 1 The Wumpus Game StenchBreeze Stench Gold Breeze StenchBreeze Start Breeze.
![Page 1: 1 The Wumpus Game StenchBreeze Stench Gold Breeze StenchBreeze Start Breeze.](https://reader035.fdocuments.in/reader035/viewer/2022062500/5697bfa31a28abf838c96dce/html5/thumbnails/1.jpg)
1
The Wumpus Game
Stench Breeze
BreezeStenchGold
Breeze
Stench Breeze
Start Breeze Breeze
![Page 2: 1 The Wumpus Game StenchBreeze Stench Gold Breeze StenchBreeze Start Breeze.](https://reader035.fdocuments.in/reader035/viewer/2022062500/5697bfa31a28abf838c96dce/html5/thumbnails/2.jpg)
2
The Wumpus Game• Stench in the square containing the wumpus
and in the directly adjacent squares
• Breeze in the squares directly adjacent to a pit
• Glitter in the square where the gold is
• Bump when an agent walks into a wall
• Scream when the wumpus is killed
![Page 3: 1 The Wumpus Game StenchBreeze Stench Gold Breeze StenchBreeze Start Breeze.](https://reader035.fdocuments.in/reader035/viewer/2022062500/5697bfa31a28abf838c96dce/html5/thumbnails/3.jpg)
3
The Wumpus Game• Agent’s percept: [Stench, Breeze, Glitter, Bump, Scream]
• Agent’s actions:– Go forward, turn right 90o, turn left 90o
– Grab to pick up an object in the same square– Fire 1 arrow in a straight line in the faced direction – Climb to leave the cave
• Death if entering a square of a pit or a live wumpus
• Agent’s goal: find and bring the gold back to the start
![Page 4: 1 The Wumpus Game StenchBreeze Stench Gold Breeze StenchBreeze Start Breeze.](https://reader035.fdocuments.in/reader035/viewer/2022062500/5697bfa31a28abf838c96dce/html5/thumbnails/4.jpg)
4
The Wumpus Game
Stench Breeze
BreezeStenchGold
Breeze
StenchOK
Breeze
Start A
BreezeOK
Breeze
A = Agent
B = Breeze
G = Glitter/Gold
OK = Safe square
P = Pit
S = Stench
V = Visited
W = Wumpus
![Page 5: 1 The Wumpus Game StenchBreeze Stench Gold Breeze StenchBreeze Start Breeze.](https://reader035.fdocuments.in/reader035/viewer/2022062500/5697bfa31a28abf838c96dce/html5/thumbnails/5.jpg)
5
The Wumpus Game
Stench Breeze
BreezeStenchGold
Breeze
StenchOK P?
Breeze
Start V
BreezeA P?
Breeze
A = Agent
B = Breeze
G = Glitter/Gold
OK = Safe square
P = Pit
S = Stench
V = Visited
W = Wumpus
![Page 6: 1 The Wumpus Game StenchBreeze Stench Gold Breeze StenchBreeze Start Breeze.](https://reader035.fdocuments.in/reader035/viewer/2022062500/5697bfa31a28abf838c96dce/html5/thumbnails/6.jpg)
6
The Wumpus Game
Stench Breeze
BreezeStenchGold
Breeze
StenchA OK
Breeze
Start V
BreezeV
Breeze
A = Agent
B = Breeze
G = Glitter/Gold
OK = Safe square
P = Pit
S = Stench
V = Visited
W = Wumpus
![Page 7: 1 The Wumpus Game StenchBreeze Stench Gold Breeze StenchBreeze Start Breeze.](https://reader035.fdocuments.in/reader035/viewer/2022062500/5697bfa31a28abf838c96dce/html5/thumbnails/7.jpg)
7
The Wumpus Game
Stench Breeze
BreezeStenchGold
Breeze
StenchV A
Breeze
Start V
BreezeV
Breeze
A = Agent
B = Breeze
G = Glitter/Gold
OK = Safe square
P = Pit
S = Stench
V = Visited
W = Wumpus
![Page 8: 1 The Wumpus Game StenchBreeze Stench Gold Breeze StenchBreeze Start Breeze.](https://reader035.fdocuments.in/reader035/viewer/2022062500/5697bfa31a28abf838c96dce/html5/thumbnails/8.jpg)
8
The Wumpus Game
Stench Breeze
BreezeStenchGold A
Breeze
StenchV V
Breeze
Start V
BreezeV
Breeze
A = Agent
B = Breeze
G = Glitter/Gold
OK = Safe square
P = Pit
S = Stench
V = Visited
W = Wumpus
![Page 9: 1 The Wumpus Game StenchBreeze Stench Gold Breeze StenchBreeze Start Breeze.](https://reader035.fdocuments.in/reader035/viewer/2022062500/5697bfa31a28abf838c96dce/html5/thumbnails/9.jpg)
9
Propositional Logic Syntax• Logical constants: true, false
• Propositional symbols: P, Q, …
• Logical connectives: , , , ,
• Sentences (formulas):– Logical constants– Proposition symbols– If is a sentence, then so are and ()– If and are sentences, then so are
, and
![Page 10: 1 The Wumpus Game StenchBreeze Stench Gold Breeze StenchBreeze Start Breeze.](https://reader035.fdocuments.in/reader035/viewer/2022062500/5697bfa31a28abf838c96dce/html5/thumbnails/10.jpg)
10
Propositional Logic Semantics
• Interpretation: propositional symbol true/false
• The truth value of a sentence is defined by the truth table
P Q P P Q P Q P Q P Q
false false true false false true true
false true true false true true false
true false false false true false false
true true false true true true true
![Page 11: 1 The Wumpus Game StenchBreeze Stench Gold Breeze StenchBreeze Start Breeze.](https://reader035.fdocuments.in/reader035/viewer/2022062500/5697bfa31a28abf838c96dce/html5/thumbnails/11.jpg)
11
Propositional Logic Semantics
• Satisfiable: true under an interpretation
• Valid: true under all interpretations
P Q P P (P Q) Q ((P Q) Q) P
false false false false true
false true false false true
true false false true true
true true false false true
satisfiableunsatisfiable
valid
![Page 12: 1 The Wumpus Game StenchBreeze Stench Gold Breeze StenchBreeze Start Breeze.](https://reader035.fdocuments.in/reader035/viewer/2022062500/5697bfa31a28abf838c96dce/html5/thumbnails/12.jpg)
12
Propositional Logic Semantics
• Model: an interpretation under which the sentence is true
Q
P Q
P Q
P Q
P
Q
P Q
P Q
P Q
P
![Page 13: 1 The Wumpus Game StenchBreeze Stench Gold Breeze StenchBreeze Start Breeze.](https://reader035.fdocuments.in/reader035/viewer/2022062500/5697bfa31a28abf838c96dce/html5/thumbnails/13.jpg)
13
Propositional Logic Semantics
• Entailment: KB iff every model of KB is a model of
is a logical consequence of KB
P Q P Q P Q, P
false false true false
false true true false
true false false false
true true true true
{P Q, P} Q
![Page 14: 1 The Wumpus Game StenchBreeze Stench Gold Breeze StenchBreeze Start Breeze.](https://reader035.fdocuments.in/reader035/viewer/2022062500/5697bfa31a28abf838c96dce/html5/thumbnails/14.jpg)
14
Propositional Logic Semantics
• Equivalence: iff and
P Q P Q P Q
false false true true
false true true true
true false false false
true true true true
P Q P Q
![Page 15: 1 The Wumpus Game StenchBreeze Stench Gold Breeze StenchBreeze Start Breeze.](https://reader035.fdocuments.in/reader035/viewer/2022062500/5697bfa31a28abf838c96dce/html5/thumbnails/15.jpg)
15
Propositional Logic Semantics
• Theorems: – iff is valid
KB can be proved by validity KB
– iff is unsatisfiable
KB can be proved by refutation of KB
![Page 16: 1 The Wumpus Game StenchBreeze Stench Gold Breeze StenchBreeze Start Breeze.](https://reader035.fdocuments.in/reader035/viewer/2022062500/5697bfa31a28abf838c96dce/html5/thumbnails/16.jpg)
16
Inference Rules• Rule R:
Premises:1,2,, n
Conclusion:
• Soundness: R is sound iff {1,2,, n}
![Page 17: 1 The Wumpus Game StenchBreeze Stench Gold Breeze StenchBreeze Start Breeze.](https://reader035.fdocuments.in/reader035/viewer/2022062500/5697bfa31a28abf838c96dce/html5/thumbnails/17.jpg)
17
Inference Rules• Modus Ponens:
,
-Elimination:12n
i
![Page 18: 1 The Wumpus Game StenchBreeze Stench Gold Breeze StenchBreeze Start Breeze.](https://reader035.fdocuments.in/reader035/viewer/2022062500/5697bfa31a28abf838c96dce/html5/thumbnails/18.jpg)
18
Inference Rules -Introduction:
1, 2, … , n
1 2 … n
-Introduction:i
1 2 … n
![Page 19: 1 The Wumpus Game StenchBreeze Stench Gold Breeze StenchBreeze Start Breeze.](https://reader035.fdocuments.in/reader035/viewer/2022062500/5697bfa31a28abf838c96dce/html5/thumbnails/19.jpg)
19
Inference Rules• Double-negation elimination:
![Page 20: 1 The Wumpus Game StenchBreeze Stench Gold Breeze StenchBreeze Start Breeze.](https://reader035.fdocuments.in/reader035/viewer/2022062500/5697bfa31a28abf838c96dce/html5/thumbnails/20.jpg)
20
Resolution• Unit resolution:
P1 … Pi … Pn, QPi Q (all Pi and Q are literals)
P1 … Pi-1 Pi+1 … Pn
• Full resolution:
P1 … Pi … Pn, Q1 … Qj … Qm
Pi Qj P1 … Pi-1 Pi+1 … Pn Q1 … Qj-1 Qj+1 … Qm
![Page 21: 1 The Wumpus Game StenchBreeze Stench Gold Breeze StenchBreeze Start Breeze.](https://reader035.fdocuments.in/reader035/viewer/2022062500/5697bfa31a28abf838c96dce/html5/thumbnails/21.jpg)
21
Resolution• Conjunctive normal form (CNF): conjunction of
disjunctions of literals
(L11 … L1k) … (Ln1 … Lnm)
clause
• k-CNF: each clause contains at most k literals
• Every sentence can be written in CNF
![Page 22: 1 The Wumpus Game StenchBreeze Stench Gold Breeze StenchBreeze Start Breeze.](https://reader035.fdocuments.in/reader035/viewer/2022062500/5697bfa31a28abf838c96dce/html5/thumbnails/22.jpg)
22
Inference Algorithms• To derive/assert a sentence given a knowledge
base as a set of sentences
• Inference rules + a searching algorithm
![Page 23: 1 The Wumpus Game StenchBreeze Stench Gold Breeze StenchBreeze Start Breeze.](https://reader035.fdocuments.in/reader035/viewer/2022062500/5697bfa31a28abf838c96dce/html5/thumbnails/23.jpg)
23
Inference AlgorithmsAlgorithm PL-Resolution(KB, )
input: KB and are PL sentences
output: true (to assert KB ) or false (otherwise)
Clauses = set of clauses in the CNF representation of KB New = {}
loopfor each Ci, Cj in Clauses do
Resolvents = PL-Resolve(Ci, Cj)
if Resolvents contains an empty clause then return true
New = New Resolventsif New Clauses then return falseClauses = Clauses New
![Page 24: 1 The Wumpus Game StenchBreeze Stench Gold Breeze StenchBreeze Start Breeze.](https://reader035.fdocuments.in/reader035/viewer/2022062500/5697bfa31a28abf838c96dce/html5/thumbnails/24.jpg)
24
Inference Algorithms• Soundness: every deduced answer is correct
if PL-Resolution returns true then KB
• Completeness: every correct answer is deducible
if KB then PL-Resolution returns true
![Page 25: 1 The Wumpus Game StenchBreeze Stench Gold Breeze StenchBreeze Start Breeze.](https://reader035.fdocuments.in/reader035/viewer/2022062500/5697bfa31a28abf838c96dce/html5/thumbnails/25.jpg)
25
Inference Algorithms• PL-Resolution is sound and complete
• Modus Ponens with any searching algorithm is not complete
KB = {P Q, Q R}, = P R
![Page 26: 1 The Wumpus Game StenchBreeze Stench Gold Breeze StenchBreeze Start Breeze.](https://reader035.fdocuments.in/reader035/viewer/2022062500/5697bfa31a28abf838c96dce/html5/thumbnails/26.jpg)
26
Inference Algorithms• Horn clause: disjunction of literals of which at
most one is positiveP1 P2 … Pn Q
orP1 P2 … Pn Q
• Forward or backward chaining can be used for inference on Horn clauses
![Page 27: 1 The Wumpus Game StenchBreeze Stench Gold Breeze StenchBreeze Start Breeze.](https://reader035.fdocuments.in/reader035/viewer/2022062500/5697bfa31a28abf838c96dce/html5/thumbnails/27.jpg)
27
Satisfiability Problem • SAT problem: to determine if a sentence is
satisfiable
(to determine if the symbols in the sentence can be assigned true/false as to make it evaluate to true)
(D B C) (B A C) (C B E)
(E D B) (B E C)
![Page 28: 1 The Wumpus Game StenchBreeze Stench Gold Breeze StenchBreeze Start Breeze.](https://reader035.fdocuments.in/reader035/viewer/2022062500/5697bfa31a28abf838c96dce/html5/thumbnails/28.jpg)
28
Satisfiability Problem • SAT problem in propositional logic is NP-
complete
This does not mean all instances of PL inference has the exponential complexity
Polynomial-time inference procedures for Horn clauses
• Many combinatorial problems in computer science can be reduced to SAT
![Page 29: 1 The Wumpus Game StenchBreeze Stench Gold Breeze StenchBreeze Start Breeze.](https://reader035.fdocuments.in/reader035/viewer/2022062500/5697bfa31a28abf838c96dce/html5/thumbnails/29.jpg)
29
Satisfiability Problem • Backtracking algorithms
• Davis and Putnam (1960)
• Davis, Logemann, Loveland (1962)
![Page 30: 1 The Wumpus Game StenchBreeze Stench Gold Breeze StenchBreeze Start Breeze.](https://reader035.fdocuments.in/reader035/viewer/2022062500/5697bfa31a28abf838c96dce/html5/thumbnails/30.jpg)
30
Satisfiability Problem • DPLL algorithm:
– Recursive, depth-first enumeration of possible models
– Early termination: a clause is true if any literal is true
(A B) (A C) is true if A is true regardless of B and C
– Pure symbol: has the same sign in all clauses
(A B) (B C) (C A)
A model would have the literals of pure symbols assigned true
Satisfied clause removal makes new pure symbols
– Unit clause: has just one literal
Unit clause satisfaction makes new unit clauses (unit propagation)
![Page 31: 1 The Wumpus Game StenchBreeze Stench Gold Breeze StenchBreeze Start Breeze.](https://reader035.fdocuments.in/reader035/viewer/2022062500/5697bfa31a28abf838c96dce/html5/thumbnails/31.jpg)
31
Satisfiability Problem • Local search algorithms
Evaluation function counts the number of unsatisfied clauses
• Randomness to escape local minima
Flipping the truth value of one symbol at a time
![Page 32: 1 The Wumpus Game StenchBreeze Stench Gold Breeze StenchBreeze Start Breeze.](https://reader035.fdocuments.in/reader035/viewer/2022062500/5697bfa31a28abf838c96dce/html5/thumbnails/32.jpg)
32
Statisfiability Problem Algorithm WalkSAT(Clauses, p, max_flips)
input: p is flipping probability, max_flips is number of flips allowed
output: a model or failure
Model = a random assignment of truth values to the symbols
for i = 1 to max_flips do
if Model satisfies Clauses then return Model
C = a randomly selected clause from Clauses that is false in Model
with probability p flip the value in Model of a symbol from C
else flip whichever symbol in C to maximizes no. of satisfied clauses
return failure
![Page 33: 1 The Wumpus Game StenchBreeze Stench Gold Breeze StenchBreeze Start Breeze.](https://reader035.fdocuments.in/reader035/viewer/2022062500/5697bfa31a28abf838c96dce/html5/thumbnails/33.jpg)
33
Satisfiability Problem • Complexity depends on the clause/symbol ratio
Hard when the ratio is from than 4.3
• WalkSAT is much faster than DPLL
![Page 34: 1 The Wumpus Game StenchBreeze Stench Gold Breeze StenchBreeze Start Breeze.](https://reader035.fdocuments.in/reader035/viewer/2022062500/5697bfa31a28abf838c96dce/html5/thumbnails/34.jpg)
34
Inference Monotonicity• Monotonicity: the set of entailed sentences
can only increase when information is added to the KB
if KB1 then (KB1KB2)
• Propositional logic is monotone
![Page 35: 1 The Wumpus Game StenchBreeze Stench Gold Breeze StenchBreeze Start Breeze.](https://reader035.fdocuments.in/reader035/viewer/2022062500/5697bfa31a28abf838c96dce/html5/thumbnails/35.jpg)
35
An Agent for the Wumpus Game
• Knowledge Base: Xij = column i, row j
S11 B11 R1: S11 W11 W12 W21
S21 B21 R2: S21 W11 W21 W22 W31
S12 B12 R3: S12 W11 W12 W22 W13
R4: S12 W13 W12 W22 W11
![Page 36: 1 The Wumpus Game StenchBreeze Stench Gold Breeze StenchBreeze Start Breeze.](https://reader035.fdocuments.in/reader035/viewer/2022062500/5697bfa31a28abf838c96dce/html5/thumbnails/36.jpg)
36
Agent for the Wumpus Game• Finding the wumpus:
– Modus Ponens (S11 + R1): W11 W12 W21
-Elimination: W11 W12 W21
– Modus Ponens (S21 + R2): W11 W21 W22 W31
-Elimination: W11 W21 W22 W31
– Modus Ponens (S12 + R4): W13 W12 W22 W11
– Unit resolution (W11 + W13 W12 W22 W11):
W13 W12 W22
– Unit resolution (W22 + W13 W12 W22): W13 W12
– Unit resolution (W12 + W13 W12): W13
![Page 37: 1 The Wumpus Game StenchBreeze Stench Gold Breeze StenchBreeze Start Breeze.](https://reader035.fdocuments.in/reader035/viewer/2022062500/5697bfa31a28abf838c96dce/html5/thumbnails/37.jpg)
37
Agent for the Wumpus Game• Translating knowledge into action:
A11 EastA W21 Forward
![Page 38: 1 The Wumpus Game StenchBreeze Stench Gold Breeze StenchBreeze Start Breeze.](https://reader035.fdocuments.in/reader035/viewer/2022062500/5697bfa31a28abf838c96dce/html5/thumbnails/38.jpg)
38
Agent for the Wumpus Game• Problems with the propositional agent:
– Too many propositions to handle:
"Don’t go forward if the wumpus is in front of you!" requires 16 x 4 = 64 propositions.
– Hard to deal with time and change
– Not expressive enough to represent or answer a question like "What action should the agent take?", …
![Page 39: 1 The Wumpus Game StenchBreeze Stench Gold Breeze StenchBreeze Start Breeze.](https://reader035.fdocuments.in/reader035/viewer/2022062500/5697bfa31a28abf838c96dce/html5/thumbnails/39.jpg)
39
Homework• In Russell & Norvig’s AIMA (2nd ed.): Exercises
of Chapter 7.