70 likes | 157 Views
Ch. 7 – Logical Agents. Supplemental slides for CSE 327 Prof. Jeff Heflin. Goal-Based 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.
E N D
Ch. 7 – Logical Agents Supplemental slides for CSE 327 Prof. Jeff Heflin
Goal-Based 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 actionpersistent: KB, a knowledge baset, a counter, initially 0 indicating time Tell(KB, Make-Percept-Sentence(percept, t)) actionASK(KB, Make-Action-Query(t))Tell(KB, Make-Action-Sentence(action, t))t t + 1return action From Figure 7.1, p. 236
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 Not Entailed! Entailed! Entailed! Assume KB={PQ, Q, QR}
Inference via Model Checking function TT-Entails?(KB, ) returns true or false symbols a list of the proposition symbols in KB and returnTT-Check-All(KB, , symbols, {}) functionTT-Check-All(KB, , symbols, model) returns true or false ifEmpty?(symbols) thenifPL-True?(KB, model) then returnPL-True?(, model)else return trueelse doPFirst(symbols); rest Rest(symbols) returnTT-Check-All(KB, , rest, model {P=true} andTT-Check-All(KB, , rest, model {P=false}) From Figure 7.10, p. 248
Wumpus World Agent function HYBRID-WUMPUS-AGENT(percept) returns an actioninputs: percept, a list [stench, breeze, glitter]persistent: KB, a knowledge base, contains “rules” of the Wumpus worldx, y, orientation, the agent’s position visited, array of squares visited by agent, initially emptyaction, most recent action, initially nullplan, an action sequence, initially empty update x, y, orientation, visited based on actionifstenchthenTell(KB, Sx,y) else Tell(KB, Sx,y) ifbreezethenTell(KB, Bx,y) else Tell(KB, Bx,y) ifglitterthenaction grabelse if plan is nonempty then action Pop(plan)else if for some frontier square [i,j], Ask(KB, (Pi,j Wi,j)) is trueor for some frontier square [i,j], Ask(KB, (Pi,j Wi,j)) is falsethen do plan A*-Graph-Search(Route-Problem([x,y], orientation,[i,j], visited))action Pop(plan)else action a randomly chosen movereturn action Simplified version of agent described in Figure 7.20, p. 270