Supplemental slides for CSE 327 Prof. Jeff Heflin Ch. 7 – Logical Agents Supplemental slides for CSE 327 Prof. Jeff Heflin
Goal-Based Agent Environment Agent sensors State What the world is like now How the world evolves Environment What it will be like if I do action A What my actions do What action I should do now Goals actuators Agent From Fig. 2.13, p. 52
Knowledge-Based Agent function KB-Agent(percept) returns an action persistent: KB, a knowledge base t, a counter, initially 0 indicating time Tell(KB, Make-Percept-Sentence(percept, t)) action ASK(KB, Make-Action-Query(t)) Tell(KB, Make-Action-Sentence(action, t)) t t + 1 return action From Figure 7.1, p. 236
Example KB Sentences For an adventure game AI, specified informally: State of the world I am healthy A wall is in front of me Effects of actions If I fall in a pit, I will die If I shoot something, I will injure it Changing goals If I see an enemy, then attack If I am injured, then retreat
Grammar for Propositional Logic Sentence AtomicSentence | ComplexSentence AtomicSentence True | False | Symbol Symbol P | Q | R | … ComplexSentence ( Sentence ) | [ Sentence ] | Sentence | (Sentence Sentence) | (Sentence Sentence) | (Sentence Sentence) | (Sentence Sentence) From Figure 7.7, p. 244
Checking Entailment Entailed! Not Entailed! Entailed! Assume KB={PQ, Q, QR} P Q R 1: PQ 2: Q 3: QR KB: 1 2 3 P PR F T
Inference via Model Checking function TT-Entails?(KB, ) returns true or false symbols a list of the proposition symbols in KB and return TT-Check-All(KB, , symbols, {}) function TT-Check-All(KB, , symbols, model) returns true or false if Empty?(symbols) then if PL-True?(KB, model) then return PL-True?(, model) else return true else do P First(symbols); rest Rest(symbols) return TT-Check-All(KB, , rest, model {P=true} and TT-Check-All(KB, , rest, model {P=false}) From Figure 7.10, p. 248 This topic will not be covered this year.
Wumpus World Agent function HYBRID-WUMPUS-AGENT(percept) returns an action inputs: percept, a list [stench, breeze, glitter] persistent: KB, a knowledge base, contains “rules” of the Wumpus world x, y, orientation, the agent’s position visited, array of squares visited by agent, initially empty action, most recent action, initially null plan, an action sequence, initially empty update x, y, orientation, visited based on action if stench then Tell(KB, Sx,y) else Tell(KB, Sx,y) if breeze then Tell(KB, Bx,y) else Tell(KB, Bx,y) if glitter then action grab else if plan is nonempty then action Pop(plan) else if for some frontier square [i,j], Ask(KB, (Pi,j Wi,j )) is true or for some frontier square [i,j], Ask(KB, (Pi,j Wi,j )) is false then do plan A*-Graph-Search(Route-Problem([x,y], orientation, [i,j], visited)) action Pop(plan) else action a randomly chosen move return action Simplified version of agent described in Figure 7.20, p. 270