movement
Class RandomWalk

java.lang.Object
  extended by movement.MovementModel
      extended by movement.RandomWalk
All Implemented Interfaces:
SwitchableMovement

public class RandomWalk
extends MovementModel
implements SwitchableMovement

Random Walk movement model


Field Summary
 
Fields inherited from class movement.MovementModel
comBus, DEF_SPEEDS, DEF_WAIT_TIMES, maxSpeed, maxWaitTime, minSpeed, minWaitTime, MOVEMENT_MODEL_NS, rng, RNG_SEED, SPEED, WAIT_TIME, WORLD_SIZE
 
Constructor Summary
RandomWalk(Settings settings)
           
 
Method Summary
 Coord getInitialLocation()
          Returns a possible (random) placement for a host
 Coord getLastLocation()
          Get the last location the getPath() of this movement model has returned
 Path getPath()
          Returns a new path by this movement model or null if no new path could be constructed at the moment (node should wait where it is).
 boolean isReady()
          Checks if the movement model is finished doing its task and it's time to switch to the next movement model.
 RandomWalk replicate()
          Creates a replicate of the movement model.
 void setLocation(Coord lastWaypoint)
          Tell the movement model what its current location is
 
Methods inherited from class movement.MovementModel
generateSpeed, generateWaitTime, getComBus, getMaxX, getMaxY, isActive, nextPathAvailable, reset, setComBus, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RandomWalk

public RandomWalk(Settings settings)
Method Detail

getInitialLocation

public Coord getInitialLocation()
Returns a possible (random) placement for a host

Specified by:
getInitialLocation in class MovementModel
Returns:
Random position on the map

getPath

public Path getPath()
Description copied from class: MovementModel
Returns a new path by this movement model or null if no new path could be constructed at the moment (node should wait where it is). A new path should not be requested before the destination of the previous path has been reached.

Specified by:
getPath in class MovementModel
Returns:
A new path or null

replicate

public RandomWalk replicate()
Description copied from class: MovementModel
Creates a replicate of the movement model.

Specified by:
replicate in class MovementModel
Returns:
A new movement model with the same settings as this model

getLastLocation

public Coord getLastLocation()
Description copied from interface: SwitchableMovement
Get the last location the getPath() of this movement model has returned

Specified by:
getLastLocation in interface SwitchableMovement
Returns:
the last location

setLocation

public void setLocation(Coord lastWaypoint)
Description copied from interface: SwitchableMovement
Tell the movement model what its current location is

Specified by:
setLocation in interface SwitchableMovement

isReady

public boolean isReady()
Description copied from interface: SwitchableMovement
Checks if the movement model is finished doing its task and it's time to switch to the next movement model. The method should be called between getPath() calls.

Specified by:
isReady in interface SwitchableMovement
Returns:
true if ready