SEdit.Formalisms.World
Class MobileEntity

java.lang.Object
  extended by SEdit.SElement
      extended by SEdit.SNode
          extended by SEdit.Formalisms.World.WorldEntity
              extended by SEdit.Formalisms.World.MobileEntity
Direct Known Subclasses:
AbstractAnt, Animal, RandomEntity, SimpleEntity

public class MobileEntity
extends WorldEntity


Field Summary
static int BOUND
          Movement type which supposes that the world is bounded
static double convDegGrad
           
static double convGradDeg
           
protected  int movementType
          Current movement type.
static int WRAP
          Movement type which supposes that the world is toric
 
Fields inherited from class SEdit.Formalisms.World.WorldEntity
behaviorFileName, brainClass
 
Fields inherited from class SEdit.SElement
comment, descriptor, element, id, label, persistent, structure
 
Constructor Summary
MobileEntity()
           
 
Method Summary
 void avoidObstacles(java.util.Vector ents)
          Avoid obstacles by bouncing on them.
 java.util.Vector detect()
          Returns a vector of all entities detected within the current detecting range.
 void directTowards(WorldEntity e)
          Heads the body into the direction of an entity e
 int getDetectingRange()
          Get the current detecting range
 int getDirection()
           
 int getDirectionTo(java.awt.Point p)
          Computes and returns the direction which heads to a position given by a Point p.
 int getDirectionTo(WorldEntity e)
          Computes and returns the direction which heads to the position of an entity e.
 int getDistanceTo(WorldEntity e)
          Computes and returns the distance between the mobile entity and an entity e.
 int getMaxSpeed()
          Returns the maximum speed of a body
 int getSpeed()
          get the current speed of a body.
 void init()
          Initialization method called at the end of the creation of an element.
 boolean isDetecting()
          indicates whether the body detects an entity or not
 boolean isTouching(WorldEntity e)
          Indicates if this mobile entity touches a world entity
 void move()
          Moves the body at its speed
 void moveTo(WorldEntity e)
          Move in the direction of an entity e.
 void randomDir()
          Gives a random direction to the body.
 void randomMove()
          moves a body into a random direction.
 void setDetecting(boolean b)
          Set if the body can detect entities or not
 void setDetectingRange(int r)
          Set the detecting rang.
 void setDirection(int r)
          Set the current direction of a body.
 void setMaxSpeed(int r)
          Set the maximum speed at which a body can move
 void setRandomCptMax(int n)
           
 void setSpeed(int r)
          Set the current speed of a body.
 
Methods inherited from class SEdit.Formalisms.World.WorldEntity
addInArrow, addOutArrow, afterDoIt, beforeDoIt, bodyDoIt, delete, doIt, getBehaviorFileName, getBrain, getBrainClass, getDistance, getInArrows, getLocation, getOutArrows, getPosition, isConnectable, makeBrain, selfDelete, setBehaviorFileName, setBrain, setBrainClass, showLine, toString
 
Methods inherited from class SEdit.SNode
activate, deleteInArrow, deleteOutArrow, initGraphics, reInstall
 
Methods inherited from class SEdit.SElement
dump, getComment, getDescriptor, getGObject, getID, getLabel, getStructure, inspect, setComment, setDescriptor, setGObject, setID, setLabel, setStructure
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

convDegGrad

public static final double convDegGrad
See Also:
Constant Field Values

convGradDeg

public static final double convGradDeg
See Also:
Constant Field Values

BOUND

public static int BOUND
Movement type which supposes that the world is bounded


WRAP

public static int WRAP
Movement type which supposes that the world is toric


movementType

protected int movementType
Current movement type. WRAP is the default. Note: this should be set in the environment and not here...

Constructor Detail

MobileEntity

public MobileEntity()
Method Detail

setMaxSpeed

public void setMaxSpeed(int r)
Set the maximum speed at which a body can move


getMaxSpeed

public int getMaxSpeed()
Returns the maximum speed of a body


setSpeed

public void setSpeed(int r)
Set the current speed of a body. Its speed cannot be higher than speedMax


getSpeed

public int getSpeed()
get the current speed of a body.


setDirection

public void setDirection(int r)
Set the current direction of a body. In degree. 0 degree heads towards the right.


getDirection

public int getDirection()

setDetecting

public void setDetecting(boolean b)
Set if the body can detect entities or not


isDetecting

public boolean isDetecting()
indicates whether the body detects an entity or not


setDetectingRange

public void setDetectingRange(int r)
Set the detecting rang.


getDetectingRange

public int getDetectingRange()
Get the current detecting range


init

public void init()
Description copied from class: SElement
Initialization method called at the end of the creation of an element. By default do nothing

Overrides:
init in class SElement

move

public void move()
Moves the body at its speed


directTowards

public void directTowards(WorldEntity e)
Heads the body into the direction of an entity e


getDirectionTo

public int getDirectionTo(WorldEntity e)
Computes and returns the direction which heads to the position of an entity e.


getDirectionTo

public int getDirectionTo(java.awt.Point p)
Computes and returns the direction which heads to a position given by a Point p.


getDistanceTo

public int getDistanceTo(WorldEntity e)
Computes and returns the distance between the mobile entity and an entity e.


moveTo

public void moveTo(WorldEntity e)
Move in the direction of an entity e. This is a simple combination of directTowards and move.


detect

public java.util.Vector detect()
Returns a vector of all entities detected within the current detecting range.


avoidObstacles

public void avoidObstacles(java.util.Vector ents)
Avoid obstacles by bouncing on them. This is a very bad method and its behavior will soon be modified...


isTouching

public boolean isTouching(WorldEntity e)
Indicates if this mobile entity touches a world entity


randomDir

public void randomDir()
Gives a random direction to the body. This method does not use the randomCptMax parameter


setRandomCptMax

public void setRandomCptMax(int n)

randomMove

public void randomMove()
moves a body into a random direction. The body goes into the same direction randomCptMax time unit. The parameter randomCptMax may be modified using the setRandomCptMax method



Copyright © Madkit Team (O. Gutknecht, J. Ferber, F. Michel et al.) All Rights Reserved.