230 likes | 309 Views
The Wumpus example. A toy world for logical exploration. Wumpus world. A four by four cave with locations identified by coordinates (3,4) , etc. Agent is at a location, facing a particular direction (L,R,D,U) Agent starts at (1,1) facing R. 4. >. 1. 1. 4. Wumpus world. In the cave is:
E N D
The Wumpus example A toy world for logical exploration
Wumpus world • A four by four cave with locations identified by coordinates (3,4), etc. • Agent is at a location, facing a particular direction (L,R,D,U) • Agent starts at (1,1) facing R 4 > 1 1 4 D. Goforth, fall 2006
Wumpus world • In the cave is: • A wumpus that smells • It can kill the agent if at same location • It can be killed by the agent shooting an arrow if facing the wumpus. When the wumpus dies, it SCREAMs 4 ^ 1 1 4 D. Goforth, fall 2006
Wumpus world • In the cave are: • 3 Pits. Breezes blow from pits. • If an agent steps into a pit, it falls to its death. • A heap of gold that glitters 4 ^ 1 1 4 D. Goforth, fall 2006
Wumpus world • Agent goal: • get gold and get out alive • Agent actions: • Move forward one square in current direction (Fwd) • Turn left or right 90o (TL,TR) • Shoot arrow in current direction • Grab gold • Agent perceptions at each location: • [Stench, Breeze, Glitter, Bump, Scream] D. Goforth, fall 2006
Wumpus world • Cave is created randomly (location of wumpus, pits and gold) • Perception / action loop • Agent must construct a model – knowledge base about the cave – as it tries to achieve its goal 4 > 1 1 4 D. Goforth, fall 2006
Wumpus world knowledge • General knowledge (known at start) • Location and direction • Living • Grab and holding • Wumpus and stench, shooting, scream, life • Pits and breeze • Gold and glitter • Movement and location, direction and bumps • Starting state of agent • Goal • Facts (not known) • Location of wumpus, pits, gold D. Goforth, fall 2006
Wumpus world in propositional logic • Facts are propositions: • e.g., W44 “Wumpus is at square (4,4) • 96 propositions (16 each for wumpus, stench, pit, breeze, gold, glitter) to represent a particular cave • General knowledge in sentences: • e.g., W44(S44 S43 S34) “if the wumpus is at (4,4), there is stench at (4,4), (4,3) and (3,4)” • “many” sentences D. Goforth, fall 2006
Wumpus world in propositional logic • Facts that may change: • Location of agent, direction of agent • Agent holding gold • Agent has shot arrow • Agent, wumpus are alive timed logic proliferation of propositions D. Goforth, fall 2006
Wumpus world in FOL • the objects in the environment • terms: constants, variables, functions • constants: • times: 0, 1, 2, ... • headings: R, L, D, U • coordinates: 1, 2, 3, 4 • locations: 16 squares • percepts: Stench, Breeze, Glitter, Bump, Scream, None • actions: Turn(Left), Turn(Right), Forward, Grab, Shoot • Agent, Wumpus D. Goforth, fall 2006
Wumpus world in FOL • the objects in the environment • terms: constants, variables, functions • functions: • Square(x,y) // [x,y] p.259 • Home(Wumpus) • Perception(s, b, g, h, y) // [s, b, g, h, y] p.258 • Heading(t), Location(t) D. Goforth, fall 2006
Wumpus world in FOL • the basic knowledge • atomic sentences: predicates, term=term • predicates: (true or false) • properties (of one term/object) • Breezy(t) // agent feeling breeze at time t • Breeze(s) // breeze blowing on square s • Pit(s), Gold(s), etc. • Time(x) // object x is a time • Coordinate(x), Action(x), Heading(x), etc. D. Goforth, fall 2006
Wumpus world in FOL • the basic knowledge • atomic sentences: predicates, term=term • predicates: (true or false) • relations (of multiple terms/objects) • At(s,t) // agent on square s at time t* • Adjacent (r,s) // squares r and s are adjacent • Alive(x,t) // x is alive at time t • Percept(p,t) // perception at time t • BestAction(a,t) // action a to take at time t D. Goforth, fall 2006 *compare with p.259
Wumpus world in FOL • the basic knowledge • atomic sentences: predicates, term=term • term = term: (true or false) • Home(Wumpus) = [3,3] • Heading(5) = U D. Goforth, fall 2006
Wumpus world in FOL • the knowledge base • General knowledge • Facts that are fixed • Facts that may change over time Compound sentences Atomic sentences D. Goforth, fall 2006
Wumpus world in FOL • the knowledge base • General knowledge • Facts that are constant • Facts that may change over time D. Goforth, fall 2006
Exploring Wumpus world in FOL Initial conditions: known unknown After first perception P0, actionA0: known new unknown P0 A0 D. Goforth, fall 2006
Exploring Wumpus world in FOL After first perception P0, actionA0: known new unknown After second perception P1, actionA1 P0 P1 A0 A1 D. Goforth, fall 2006
Exploring Wumpus world in FOL Timed atomic sentences: Initial conditions At([1,1],0) Heading(R,0) Alive(Agent,0) Alive(Wumpus,0) then First perception: Percept([Stench,None, None, None, None],0) D. Goforth, fall 2006
Exploring Wumpus world in FOL Percept([Stench, None, None, None, None],0) Understanding what is perceived ∀b ∀g ∀h ∀y ∀t Percept([Stench,b,g, h, y],t)⇒Stinky(t) ∀s ∀g ∀h ∀y ∀t Percept([s,None,g, h, y],t)⇒Glittery(t) Stinky(0) Glittery(0) ∀r ∀t Stinky(t) At(r,t) ⇒ Stinks(r) ∀r ∀t Glittery(t) At(r,t) ⇒ Glitters(r) Stinks([1,1]) Glitters ([1,1]) Fixed knowledge D. Goforth, fall 2006
Exploring Wumpus world in FOL Updating timed knowledge: All atomic sentences may be different from t to t+1 BUT Most are the same UNLESS An action changes them ∀r ∀t At(r,t) (BestAction(Forward,t) (Bumped(t+1)) ⇒At(r,t+1) ∀tScreams(t) ⇒ Alive(Wumpus,t) Time t Time t+1 D. Goforth, fall 2006
Exploring Wumpus world in FOL Deciding the best action (incomplete description here): Need to reason about the cave conditions Diagnostic rules (p.259) ∀s Breezy(s) ⇒ ∃r Adjacent(r,s) Pit(r) Causal rules (p.260) ∀r Pit(r) ⇒ [∀s Adjacent(r,s) ⇒ Breezy(s)] D. Goforth, fall 2006