A SNePS Approach to The Wumpus World Agent or Cassie Meets the Wumpus Stuart C. Shapiro & Michael Kandefer Department of Computer Science and Engineering, and Center for Cognitive Science University at Buffalo, The State University of New York 201 Bell Hall, Buffalo, NY 14260-2000 {shapiro|mkw3}@cse.buffalo.edu http://www.cse.buffalo.edu/~{shapiro|mkw3}/ : perform get(gold) No breeze here. No stench here. Exploring the cave... Found a safe room... NRAC-05 S. C. Shapiro & M. Kandefer 2 I am in room (1, 0), facing east No breeze here. No stench here. Exploring the cave... Found a safe room... NRAC-05 S. C. Shapiro & M. Kandefer 3 NRAC-05 S. C. Shapiro & M. Kandefer 4 I am in room (1, 1), facing south I feel a breeze. No stench here. Exploring the cave... Found a safe room... NRAC-05 S. C. Shapiro & M. Kandefer 5 NRAC-05 S. C. Shapiro & M. Kandefer 6 I am in room (0, 1), facing west No breeze here. No stench here. Exploring the cave... Found a safe room... NRAC-05 S. C. Shapiro & M. Kandefer 7 NRAC-05 S. C. Shapiro & M. Kandefer 8 I am in room (0, 2), facing south I feel a breeze. No stench here. Exploring the cave... Visiting an old room... This is boring. NRAC-05 S. C. Shapiro & M. Kandefer 9 NRAC-05 S. C. Shapiro & M. Kandefer 10 Exploring the cave... Visiting an old room... This is boring. NRAC-05 S. C. Shapiro & M. Kandefer 11 Exploring the cave... Visiting an old room... This is boring. NRAC-05 S. C. Shapiro & M. Kandefer 12 NRAC-05 S. C. Shapiro & M. Kandefer 13 Exploring the cave... Found a safe room... NRAC-05 S. C. Shapiro & M. Kandefer 14 I am in room (2, 0), facing east I feel a breeze. No stench here. Exploring the cave... Visiting an old room... This is boring. NRAC-05 S. C. Shapiro & M. Kandefer 15 NRAC-05 S. C. Shapiro & M. Kandefer 16 Exploring the cave... Visiting an old room... This is boring. NRAC-05 S. C. Shapiro & M. Kandefer 17 Exploring the cave... Visiting an old room... This is boring. NRAC-05 S. C. Shapiro & M. Kandefer 18 NRAC-05 S. C. Shapiro & M. Kandefer 19 Exploring the cave... Visiting an old room... This is boring. NRAC-05 S. C. Shapiro & M. Kandefer 20 NRAC-05 S. C. Shapiro & M. Kandefer 21 Exploring the cave... I'll chance a move... NRAC-05 S. C. Shapiro & M. Kandefer 22 I am in room (1, 2), facing south No breeze here. I'm grabbing for the gold. No stench here. I'm going home! NRAC-05 S. C. Shapiro & M. Kandefer 23 NRAC-05 S. C. Shapiro & M. Kandefer 24 NRAC-05 S. C. Shapiro & M. Kandefer 25 NRAC-05 S. C. Shapiro & M. Kandefer 26 NRAC-05 S. C. Shapiro & M. Kandefer 27 Score = 966. NRAC-05 S. C. Shapiro & M. Kandefer 28 Formalism Used • SNePS KRR system • SNeRE acting subsystem NRAC-05 S. C. Shapiro & M. Kandefer 29 Strategy • Wander semi-randomly until find gold – Opportunistically shoot the wumpus • Grab the gold • Go home • Stop NRAC-05 S. C. Shapiro & M. Kandefer 30 Semi-Random Exploration • If have an adjacent safe new room, go there • Else if totally bored, – Risk going to any adjacent new room • Might die! – If none move randomly (boring) • Else go to an old room (boring) NRAC-05 S. C. Shapiro & M. Kandefer 31 Finding Home • Lay down VisitedFrom(r2, r1) “arrows” while exploring. • No two with same r2 to cut loops. • Follow backwards to find home. NRAC-05 S. C. Shapiro & M. Kandefer 32 Finding Walls • Two walls adjacent to home room known • When bump, believe wall location NRAC-05 S. C. Shapiro & M. Kandefer 33 Important SNePS Features 1 • First-person beliefs – Not third-person “truth” about agent or world • Beliefs are current beliefs – Even if about the past • On-line acting • Reified propositions as well as acts & … • Neither states nor times are privileged NRAC-05 S. C. Shapiro & M. Kandefer 34 Important SNePS Features 2 • SNeRE acts with operational semantics – External acts: • go(right) • do(grab) • senseFor(breeze) – Control acts: • snsequence(go(right), go(right)) – Mental acts: • believe(p) • disbelieve(p) NRAC-05 S. C. Shapiro & M. Kandefer 35 Important SNePS Features 3 • SNeRE policies integrate reasoning & acting – whendo(See(glitter), do(grab)) – ActPlan(find(home), snif({if(In(cell(0,0)), do(stop)), else(…)})) NRAC-05 S. C. Shapiro & M. Kandefer 36 Important SNePS Features 4 Use of SNePS andor connective and belief revision for state constraints: andor(1,1){Facing(north), Facing(south), Facing(east), Facing(west)} Facing(east) => ~Facing(north), ~Facing(south), ~Facing(west) believe(Facing(south)) Facing(south), ~Facing(north), ~Facing(east), ~Facing(west) NRAC-05 S. C. Shapiro & M. Kandefer 37 Important SNePS Features 5 Nondeterministic Choice ~Have(gold) =>(all(r1)(In(r1) => ActPlan(explore(cave), withsome({?r2, ?d1}, SafeNewRoom(r1, ?r2, ?d1), snsequence3(turn(?d1), move(forward), believe(Bored(0))), <else clause>)))) NRAC-05 S. C. Shapiro & M. Kandefer 38 Important SNePS Features 6 Numerical Quantifier wheneverdo(Feel(breeze), withsome/3(?r, In(?r), believe(nexists(1,4,4)(c)({Adjacent(?r,c)}: {Contains(c,pit)})))) NRAC-05 S. C. Shapiro & M. Kandefer 39 Problems • The SNePS control structure – – – – – Asynchronous Multiprocessing Producer/consumer Message passing Focused bidirectional inference • Made designing the agent, viewed as a programming task, somewhat difficult. NRAC-05 S. C. Shapiro & M. Kandefer 40