AIILE.gridworld.agent.reflex
Class ReflexAgent

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byAIILE.connection.AbstractConnectionTemplate
                  extended byAIILE.gridworld.connection.AbstractGridWorld
                      extended byAIILE.gridworld.agent.AbstractGridWorldAgent
                          extended byAIILE.gridworld.agent.reflex.ReflexAgent
All Implemented Interfaces:
java.beans.beancontext.BeanContextProxy, ConnectionTemplate, GridWorld, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

public class ReflexAgent
extends AbstractGridWorldAgent

Below is a very basic agent that will traverse poorly through the Wumpus World. This is similar to the gridworld agent, but there are few new things that adhere to the Wumpus game rules. If you fall in a pit you die, if you go to the location as a live Wumpus, you die. You have one arrow to use, you use the getEnvironmentInfo().getCurrentNode().getPercepts() to view the percepts of the current node which can be a BREEZE, STENCH, SCREAM, BUMP, or GLITTER. You can get the current direction by the use of the hints class. You set the new agent move by setting the direction that you want to go. These can be found in the WumpusConstants class. North is up. If the you move bumps you into a wall a "BUMP" percept will appear in the following EnvironmentInfo. The agent must set the previous current node to the current node, otherwise you will be inside the wall.

The agent can pickup gold using the pickUpGold() method in the Move class. If the current node has gold in it the gold will disappear and isGoldPickedUp() method in the EnvironmentInfo class will return true, else it will return false. The Wumpus Environment will compare the current node sent in the Move class with it's own internal current node. If these do not match the gold will not be picked up.

The agent can shoot an arrow in a direction once. The method shootArrow() is used for this. It takes a direction as an argument. The Wumpus Environement the traverses the direction that the arrow was shoot. If the arrow hits the wumpus a "SCREAM" is provided in the following percept list. If the arrow hits a wall nothing is returned. Once the arrow is shot you can not shot another. The isArrowShot() and isWumpusDead methods in the EnvironmentInfo class will provide info about the current status of the arrow and wumpus. If the Wumpus is dead agent can move to the Wumpus's location and not die, the stench will still be around it.

This agent simply randomly chooses a direction to go using the randomDirection() method. After four moves, if the agent has not died, it will shoot an arrow in the South direction. The agent keeps moving until it is dead or gets the gold and returns to the start location. I have not ever seen it do this. It sometimes will shoot the wumpus and pick up the gold but it always hits a pit.

Since:
Nov 7, 2003
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
ReflexAgent()
          Creates a new instance of ReflexAgent
 
Method Summary
 void finish()
          This is used to finish up the agent's run if it is needed
 void init()
          can be used to initialize the agent after the agent is allowed to start
 void run()
          This method is used to run the agent, add your agent logic here
 void setStart(boolean b)
          This method must be over written to start the agent running in the environment
 
Methods inherited from class AIILE.gridworld.agent.AbstractGridWorldAgent
getEnvironmentInfo, getMove, isFinish, isStart, isValidMove, setEnvironmentInfo, setFinish, setMove, setValidMove
 
Methods inherited from class AIILE.gridworld.connection.AbstractGridWorld
receiveEnvironmentInfo, receiveFinishInfo, receiveMoveInfo, receiveStartInfo, receiveValidMoveInfo, sendEnvironmentInfo, sendFinishInfo, sendMoveInfo, sendStartInfo, sendValidMoveInfo, setEnvironmentInfoBuddy, setFinishInfoBuddy, setMoveInfoBuddy, setStartInfoBuddy, setValidMoveInfoBuddy
 
Methods inherited from class AIILE.connection.AbstractConnectionTemplate
getBeanContextProxy, receive, send
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ReflexAgent

public ReflexAgent()
Creates a new instance of ReflexAgent

Method Detail

init

public void init()
can be used to initialize the agent after the agent is allowed to start

Specified by:
init in class AbstractGridWorldAgent

run

public void run()
This method is used to run the agent, add your agent logic here

Specified by:
run in class AbstractGridWorldAgent

finish

public void finish()
This is used to finish up the agent's run if it is needed

Specified by:
finish in class AbstractGridWorldAgent

setStart

public void setStart(boolean b)
This method must be over written to start the agent running in the environment

Specified by:
setStart in interface GridWorld
Specified by:
setStart in class AbstractGridWorldAgent