ai.worlds.wumpus
Class WumpusLogic

java.lang.Object
  extended byai.worlds.wumpus.WumpusLogic
Direct Known Subclasses:
DefaultWumpusLogic

public abstract class WumpusLogic
extends java.lang.Object

A wumpus logic unit that performs logical inference about the wumpus world.

Author:
Jill Zimmerman -- jill.zimmerman@goucher.edu

Nested Class Summary
 class WumpusLogic.PathProblemState
           
 
Field Summary
 Location agentloc
          The agents location.
 java.lang.Object[][] grid
          Information the agent has stored about the world.
 HornKnowledgeBase kb
          The knowledge base.
 Location size
          The size of the world.
 ai.worlds.wumpus.WumpusLogic.WumpusGrid wumpgrid
          The graphical representation of the world.
 
Constructor Summary
WumpusLogic(int xsize, int ysize)
           
 
Method Summary
abstract  Location closestMove(java.util.Vector moves)
          Find the closest move from a list.
 void display()
          Dispay the known information inferred about the grid.
 int distance(Location loc1, Location loc2)
          Determine block distance between two locations.
 void getStatus()
          Analyze the status of each grid cell using the knowledge base.
abstract  void makeKB(HornKnowledgeBase kb)
          Make a knowledge base.
 void move(int x, int y)
          Record a move of the agent.
abstract  Location nextMove()
          Determine the next location the agent will visit.
 java.util.Vector okayMoves()
          Determine cells known to be okay.
abstract  java.util.Vector pathTo(Location loc, Location heading)
          Determine the sequence of actions which will take the agent to the given location.
 void percept(java.lang.String s, java.lang.String b)
          Add the percept information to the knowledge base.
 java.util.Vector riskyMoves()
          Determine cells that have unknown risk.
 boolean succeeded(java.util.Vector answers)
          Did the logic query succeed?.
 boolean visited(int x, int y)
          Has the cell been visited before?.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

kb

public HornKnowledgeBase kb
The knowledge base.


grid

public java.lang.Object[][] grid
Information the agent has stored about the world.


agentloc

public Location agentloc
The agents location.


size

public Location size
The size of the world.


wumpgrid

public ai.worlds.wumpus.WumpusLogic.WumpusGrid wumpgrid
The graphical representation of the world.

Constructor Detail

WumpusLogic

public WumpusLogic(int xsize,
                   int ysize)
Method Detail

makeKB

public abstract void makeKB(HornKnowledgeBase kb)
Make a knowledge base.

Parameters:
kb - is the knowledge base that will be constructed.

closestMove

public abstract Location closestMove(java.util.Vector moves)
Find the closest move from a list.

Parameters:
moves - is a list of locations to which the agent can move.
Returns:
the move that is closest to the agent's current location.

nextMove

public abstract Location nextMove()
Determine the next location the agent will visit.

Returns:
the location that the agent will move to next.

pathTo

public abstract java.util.Vector pathTo(Location loc,
                                        Location heading)
Determine the sequence of actions which will take the agent to the given location.

Parameters:
loc - is the location we wish to travel to.
heading - is the agent's current heading.
Returns:
the sequence of actions which will take the agent to the given location.

getStatus

public void getStatus()
Analyze the status of each grid cell using the knowledge base.


succeeded

public boolean succeeded(java.util.Vector answers)
Did the logic query succeed?.

Parameters:
answers - is a list of answers from the knowledge base query.
Returns:
true if any answer was obtained.

move

public void move(int x,
                 int y)
Record a move of the agent.

Parameters:
x - and y are the coordinates moved to.

visited

public boolean visited(int x,
                       int y)
Has the cell been visited before?.

Parameters:
x - and y are the coordiates of the cell.
Returns:
true if cell previously visited.

percept

public void percept(java.lang.String s,
                    java.lang.String b)
Add the percept information to the knowledge base.

Parameters:
s - is the string indicating whether the agent perceives a stench.
b - is the string indicating whether the agent perceives a breeze.

display

public void display()
Dispay the known information inferred about the grid.


okayMoves

public java.util.Vector okayMoves()
Determine cells known to be okay.

Returns:
a vector of safe cells.

riskyMoves

public java.util.Vector riskyMoves()
Determine cells that have unknown risk.

Returns:
a vector of risky cells.

distance

public int distance(Location loc1,
                    Location loc2)
Determine block distance between two locations.

Parameters:
loc1 - and loc2 are two locations.
Returns:
a distance.