modelling
Class MovingAgent

java.lang.Object
  extended bysema.Element
      extended bysema.Agent
          extended bymodelling.MovingAgent
All Implemented Interfaces:
java.lang.Comparable
Direct Known Subclasses:
AgentTestAction, RandomAgent, RandomAgentOneByBox, testMovingAgent, testMovingAgent2

public class MovingAgent
extends Agent

Agent with abilities to move.


Nested Class Summary
protected  class MovingAgent.Errer
          A default action to errate on the map without verification of the collisions with other elements.
protected  class MovingAgent.MoveTo
          Moves to the given point.
 
Nested classes inherited from class sema.Agent
Agent.Action
 
Nested classes inherited from class sema.Element
Element.ElementEvent
 
Field Summary
 
Fields inherited from class sema.Element
id, world
 
Constructor Summary
MovingAgent(World world, Area area, float delay, java.awt.Image image, float speed)
          Receives a speed and the paramaters of a normal agent.
 
Method Summary
protected  boolean acceptAction(Agent.Action a)
          Global internal heuristic method of decision as to the actions to undertake.
protected  float canSee(float angle)
          Returns the maximum distance that can be seen in this direction.
protected  boolean fitStep()
          Chooses the best direction where to move (where the largest move is possibleà and walk one step in this direction.
 float getSpeed()
          Returns the speed of the agent.
protected  boolean randomStep(float a)
           
protected  boolean rotate(float a)
          Rotation with collision check.
protected  void setSpeed(float speed)
          Sets the speed of the agent.
protected  boolean translate(float x, float y)
          Translation with collision check.
protected  boolean walk(float f)
          Walk in the direction gived by the element angle, checking collisions.
 
Methods inherited from class sema.Agent
getDelay, registerAction, setDelay, unregisterAction
 
Methods inherited from class sema.Element
canTake, compareTo, death, draw, getArea, getDrawingPriority, getHeight, getIcon, getImage, getKind, getName, getProperties, highlight, highlight, isMarked, kill, setDrawingPriority, setHeight, setKind, setMarked, setProperties, toString, union
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MovingAgent

public MovingAgent(World world,
                   Area area,
                   float delay,
                   java.awt.Image image,
                   float speed)
Receives a speed and the paramaters of a normal agent.

Method Detail

setSpeed

protected void setSpeed(float speed)
Sets the speed of the agent.


getSpeed

public final float getSpeed()
Returns the speed of the agent.


acceptAction

protected boolean acceptAction(Agent.Action a)
Description copied from class: Agent
Global internal heuristic method of decision as to the actions to undertake. It is called before each call to an action to determinate whether it should be executed. If it returns 'false', the Agent.Action.whenRefused() method is called and the action who called acceptAction is killed. This method has an overwhelming power of decision on the action, which cannot ignore this decision. The default acceptAction method always returns true. It's designed to provide an easy-to-use main decision function to manage actions.

Overrides:
acceptAction in class Agent

translate

protected boolean translate(float x,
                            float y)
Translation with collision check.


rotate

protected boolean rotate(float a)
Rotation with collision check.


walk

protected boolean walk(float f)
Walk in the direction gived by the element angle, checking collisions.


fitStep

protected boolean fitStep()
Chooses the best direction where to move (where the largest move is possibleà and walk one step in this direction.


canSee

protected float canSee(float angle)
Returns the maximum distance that can be seen in this direction. Used to detect obstacles.


randomStep

protected boolean randomStep(float a)