AI for Games 1.1.1
Loading...
Searching...
No Matches
game2dai.steering.AutoPilot Class Reference
Inheritance diagram for game2dai.steering.AutoPilot:

Public Member Functions

AutoPilot setOwner (final Vehicle vehicle)
 
boolean hasOwner ()
 
AutoPilot allOff ()
 
AutoPilot wallAvoidOff ()
 
AutoPilot wallAvoidOn ()
 
AutoPilot wallAvoidWeight (double weight)
 
double wallAvoidWeight ()
 
boolean isWallAvoidOn ()
 
AutoPilot wallAvoidFactors (Object nbrWhiskers, Object whiskerLength, Object fov, Boolean shortOnSide)
 
int wallAvoidNbrWhiskers ()
 
double wallAvoidFOV ()
 
double wallAvoidWhiskerLength ()
 
boolean isWallAvoidOvalEnvelopeOn ()
 
AutoPilot obstacleAvoidOff ()
 
AutoPilot obstacleAvoidOn ()
 
AutoPilot obstacleAvoidWeight (double weight)
 
double obstacleAvoidWeight ()
 
double obstacleAvoidDetectBoxLength ()
 
AutoPilot obstacleAvoidDetectBoxLength (double boxLength)
 
boolean isObstacleAvoidOn ()
 
AutoPilot obstacleAvoidFactors (double detectBoxLength)
 
AutoPilot evadeOff ()
 
AutoPilot evadeOn ()
 
AutoPilot evadeOn (MovingEntity me)
 
double evadeDistance ()
 
AutoPilot evadeWeight (double weight)
 
double evadeWeight ()
 
boolean isEvadeOn ()
 
AutoPilot evadeFactors (double fleeDistance)
 
AutoPilot seekOff ()
 
AutoPilot seekOn ()
 
AutoPilot seekOn (Vector2D target)
 
AutoPilot seekOn (double x, double y)
 
double seekDistance ()
 
AutoPilot seekWeight (double weight)
 
double seekWeight ()
 
boolean isSeekOn ()
 
AutoPilot arriveOff ()
 
AutoPilot arriveOn ()
 
AutoPilot arriveOn (Vector2D target)
 
AutoPilot arriveOn (Vector2D target, int speed)
 
AutoPilot arriveOn (double x, double y)
 
AutoPilot arriveOn (double x, double y, int speed)
 
double arriveDistance ()
 
AutoPilot arriveWeight (double weight)
 
double arriveWeight ()
 
boolean isArriveOn ()
 
AutoPilot fleeOff ()
 
AutoPilot fleeOn ()
 
AutoPilot fleeOn (Vector2D location)
 
AutoPilot fleeOn (double x, double y)
 
double fleeDistance ()
 
AutoPilot fleeRadius (double fleeRadius)
 
double fleeRadius ()
 
AutoPilot fleeWeight (double weight)
 
double fleeWeight ()
 
boolean isFleeOn ()
 
AutoPilot fleeFactors (double fleeDistance)
 
AutoPilot separationOff ()
 
AutoPilot separationOn ()
 
AutoPilot separationWeight (double weight)
 
double separationWeight ()
 
boolean isSeparationOn ()
 
AutoPilot alignmentOff ()
 
AutoPilot alignmentOn ()
 
AutoPilot alignmentWeight (double weight)
 
double alignmentWeight ()
 
boolean isAlignmentOn ()
 
AutoPilot cohesionOff ()
 
AutoPilot cohesionOn ()
 
AutoPilot cohesionWeight (double weight)
 
double cohesionWeight ()
 
boolean isCohesionOn ()
 
AutoPilot flockOff ()
 
AutoPilot flockOn ()
 
AutoPilot flockWeight (double weight)
 
double flockWeight ()
 
boolean isFlockOn ()
 
AutoPilot flockFactors (double neighbourhoodRadius)
 
AutoPilot wanderOff ()
 
AutoPilot wanderOn ()
 
AutoPilot wanderWeight (double weight)
 
double wanderWeight ()
 
boolean isWanderOn ()
 
AutoPilot wanderFactors (Object dist, Object radius, Object jitter)
 
double wanderRadius ()
 
double wanderDist ()
 
double wanderAngle ()
 
double wanderAngleJitter ()
 
double wanderAngleDelta ()
 
AutoPilot pursuitOff ()
 
AutoPilot pursuitOn ()
 
AutoPilot pursuitOn (MovingEntity me)
 
double pursuitDistance ()
 
AutoPilot pursuitWeight (double weight)
 
double pursuitWeight ()
 
boolean isPursuitOn ()
 
AutoPilot offsetPursuitOff ()
 
AutoPilot offsetPursuitOn ()
 
AutoPilot offsetPursuitOn (MovingEntity me, Vector2D offset)
 
AutoPilot offsetPursuitWeight (double weight)
 
double offsetPursuitWeight ()
 
boolean isOffsetPursuitOn ()
 
AutoPilot interposeOff ()
 
AutoPilot interposeOn ()
 
AutoPilot interposeOn (MovingEntity me0, MovingEntity me1)
 
AutoPilot interposeOn (MovingEntity me0, Vector2D fixedPos1)
 
AutoPilot interposeOn (Vector2D fixedPos0, Vector2D fixedPos1)
 
AutoPilot interposeWeight (double weight)
 
double interposeWeight ()
 
boolean isInterposeOn ()
 
AutoPilot hideOff ()
 
AutoPilot hideOn ()
 
AutoPilot hideOn (MovingEntity me)
 
double hideDistance ()
 
AutoPilot hideWeight (double weight)
 
double hideWeight ()
 
boolean isHideOn ()
 
AutoPilot pathOff ()
 
AutoPilot pathOn ()
 
AutoPilot pathWeight (double weight)
 
double pathWeight ()
 
boolean isPathOn ()
 
AutoPilot pathFactors (Object seekDist, Object arriveDist)
 
LinkedList< GraphNodepathRoute ()
 
int pathRouteLength ()
 
AutoPilot pathSetRoute (Vector2D[] route)
 
AutoPilot pathAddToRoute (Vector2D[] route)
 
AutoPilot pathAddToRoute (Vector2D waypoint)
 
AutoPilot pathSetRoute (List< GraphNode > route)
 
AutoPilot pathAddToRoute (List< GraphNode > route)
 
AutoPilot pathAddToRoute (Graph graph, GraphNode dest)
 
GraphNode pathNextNode ()
 
AutoPilot calculateMethod (int method)
 
int calculateMethod ()
 
Vector2D calculateForce (double deltaTime, World world)
 
Vector2D[] getFeelers ()
 
Vector2D[] getFeelers (MovingEntity me)
 
Vector2D[] getFeelers (final Vector2D facing, final Vector2D origin)
 
Object clone ()
 
String toString ()
 
double getWeight (int behaviour)
 

Protected Member Functions

Vector2D hide (MovingEntity me, MovingEntity from)
 
Vector2D alignment (MovingEntity me)
 
Vector2D separation (MovingEntity me)
 
Vector2D cohesion (MovingEntity me)
 
Vector2D flock (MovingEntity me)
 
Vector2D interpose (MovingEntity me, MovingEntity m0, MovingEntity m1)
 
Vector2D interpose (MovingEntity me, MovingEntity m0, Vector2D fixedPos)
 
Vector2D wallAvoidance (MovingEntity me)
 
Vector2D obstacleAvoidance (MovingEntity me)
 
Vector2D seek (MovingEntity me, Vector2D target)
 
Vector2D flee (MovingEntity me, Vector2D target)
 
Vector2D arrive (MovingEntity me, Vector2D target, int rate)
 
Vector2D offsetPursuit (MovingEntity me, MovingEntity leader, Vector2D offset)
 
Vector2D pursuit (MovingEntity me, MovingEntity toPursue)
 
Vector2D evade (MovingEntity me, MovingEntity evadeAgent)
 

Private Member Functions

Vector2D calculateWeightedAverage ()
 
Vector2D calculateWeightedAverage_LogForces ()
 
Vector2D calculatePrioritised ()
 
Vector2D calculatePrioritised_LogForces ()
 
boolean accumulateForce (Vector2D runningTotal, Vector2D forceToAdd, double maxForce)
 
Vector2D hide ()
 
Vector2D getHidingPosition (MovingEntity me, Obstacle ob, BaseEntity target)
 
Vector2D alignment ()
 
Vector2D separation ()
 
Vector2D cohesion ()
 
Vector2D flock ()
 
Vector2D interpose ()
 
Vector2D wallAvoidance ()
 
Vector2D[] createWhiskers (final int nbrWhiskers, final double whiskerLength, final double fov, final Vector2D facing, final Vector2D origin)
 
Vector2D obstacleAvoidance ()
 
Vector2D seek ()
 
Vector2D flee ()
 
Vector2D wander ()
 
Vector2D arrive ()
 
Vector2D offsetPursuit ()
 
Vector2D pursuit ()
 
Vector2D evade ()
 
Vector2D pathFollow ()
 

Static Private Member Functions

static int bitPos (int flag)
 

Private Attributes

Set< Obstacleobstacles = null
 
Set< Wallwalls = null
 
Set< MovingEntitymovers = null
 
double deltaTime = 0
 
World world
 
Vehicle owner = null
 
int flags = 0
 
Vector2D accum = new Vector2D()
 
Vector2D f = new Vector2D()
 
Vector2D steeringForce = new Vector2D()
 
int forceCalcMethod = WEIGHTED_PRIORITIZED
 
Vector2D gotoTarget = new Vector2D()
 
int arriveRate = NORMAL
 
double arriveDist = 0.5
 
Vector2D fleeTarget = new Vector2D()
 
double fleeRadius = 100
 
LinkedList< GraphNodepath = new LinkedList<GraphNode>()
 
double pathSeekDist = 20
 
double pathArriveDist = 0.5
 
double detectBoxLength = 20.0
 
MovingEntity[] agents = new MovingEntity[NBR_AGENT_ARRAY]
 
Vector2D pursueOffset = new Vector2D()
 
double wanderAngle = 0
 
double wanderAngleJitter = 60
 
double wanderRadius = 20.0
 
double wanderDist = 60.0
 
double wanderAngleDelta = 0
 
int nbrWhiskers = 5
 
double whiskerFOV = FastMath.PI
 
double whiskerLength = 30
 
boolean ovalEnvelope = false
 
double neighbourDist = 100.0
 
double[] weightings
 

Static Private Attributes

static double WANDER_MIN_ANGLE = -1.0 * FastMath.PI
 
static double WANDER_MAX_ANGLE = FastMath.PI
 
static double WANDER_ANGLE_RANGE = 2.0 * FastMath.PI
 
static String[] bnames
 

Additional Inherited Members

- Public Attributes inherited from game2dai.steering.SBF
int BIT_WALL_AVOID = 0
 
int BIT_OBSTACLE_AVOID = 1
 
int BIT_EVADE = 2
 
int BIT_FLEE = 3
 
int BIT_SEPARATION = 4
 
int BIT_ALIGNMENT = 5
 
int BIT_COHESION = 6
 
int BIT_SEEK = 7
 
int BIT_ARRIVE = 8
 
int BIT_WANDER = 9
 
int BIT_PURSUIT = 10
 
int BIT_OFFSET_PURSUIT = 11
 
int BIT_INTERPOSE = 12
 
int BIT_HIDE = 13
 
int BIT_PATH = 14
 
int BIT_FLOCK = 15
 
int WALL_AVOID = 1 << BIT_WALL_AVOID
 
int OBSTACLE_AVOID = 1 << BIT_OBSTACLE_AVOID
 
int EVADE = 1 << BIT_EVADE
 
int FLEE = 1 << BIT_FLEE
 
int SEPARATION = 1 << BIT_SEPARATION
 
int ALIGNMENT = 1 << BIT_ALIGNMENT
 
int COHESION = 1 << BIT_COHESION
 
int SEEK = 1 << BIT_SEEK
 
int ARRIVE = 1 << BIT_ARRIVE
 
int WANDER = 1 << BIT_WANDER
 
int PURSUIT = 1 << BIT_PURSUIT
 
int OFFSET_PURSUIT = 1 << BIT_OFFSET_PURSUIT
 
int INTERPOSE = 1 << BIT_INTERPOSE
 
int HIDE = 1 << BIT_HIDE
 
int PATH = 1 << BIT_PATH
 
int FLOCK = 1 << BIT_FLOCK
 
int ALL_SB_MASK = 0x0ffffff
 
int WEIGHTED = 1
 
int WEIGHTED_PRIORITIZED = 2
 
double[] DECEL_TWEEK = new double[] {0.0, 0.3, 0.6, 0.9}
 
int FAST = 1
 
int NORMAL = 2
 
int SLOW = 3
 
int AGENT0 = 0
 
int AGENT1 = 1
 
int AGENT_TO_PURSUE = 2
 
int AGENT_TO_EVADE = 3
 
int NBR_AGENT_ARRAY = 4
 
int PASS_THROUGH = 10000
 
int WRAP = 10001
 
int REBOUND = 10002
 

Detailed Description

AutoPilot Objects are used to control the motion of a Vehicle object by specifying a set of steering behaviours the Vehicle must obey.
Every Vehicle object has it's own AutoPilot object (An AutoPilot object cannot be shared by multiple Vehicles)

This class supports 16 different behaviours which can be combined to provide appropriate motion based on the game environments.

A large number of constants are defined to simplify the use of this class.
Behaviour constants

WALL_AVOID  OBSTACLE_AVOID      EVADE       FLEE    SEPARATION  
ALIGNMENT COHESION SEEK ARRIVE WANDER
PURSUIT OFFSET_PURSUIT INTERPOSE HIDE PATH
FLOCK



Force calculation constants. The default is WEIGHTED_PRIORITIZED

WEIGHTED   WEIGHTED_PRIORITIZED 



Agents (other Vehicle objects) to pursue, evade etc.

AGENT0  AGENT1      AGENT_TO_PURSUE     AGENT_TO_FLEE 



Author
Peter Lager

Member Function Documentation

◆ accumulateForce()

boolean game2dai.steering.AutoPilot.accumulateForce ( Vector2D  runningTotal,
Vector2D  forceToAdd,
double  maxForce 
)
private

This method is used by the PRIORITISED force calculation method.
For each active behaviour in turn it calculates how much of the maximum steering force is left then adds that amount of to the accumulator.

Parameters
runningTotalrunning total
forceToAddthe force we want to add from the current behaviour
maxForcethe maximum force available.
Returns
true if we have not reached the maximum permitted force.

◆ alignment()

Vector2D game2dai.steering.AutoPilot.alignment ( )
private

ALIGNMENT Used internally to calculate the force for this behaviour on the entity that owns this steering behaviour object.

◆ alignmentOff()

AutoPilot game2dai.steering.AutoPilot.alignmentOff ( )

Switch off alignment

Returns
this auto-pilot object

◆ alignmentOn()

AutoPilot game2dai.steering.AutoPilot.alignmentOn ( )

Switch on alignment

Returns
this auto-pilot object

◆ alignmentWeight() [1/2]

double game2dai.steering.AutoPilot.alignmentWeight ( )

Get the weighting for this behaviour

◆ alignmentWeight() [2/2]

AutoPilot game2dai.steering.AutoPilot.alignmentWeight ( double  weight)

Set the weight for this behaviour

Parameters
weightthe weighting to be applied to this behaviour.
Returns
this auto-pilot object

◆ allOff()

AutoPilot game2dai.steering.AutoPilot.allOff ( )

Switch off all steering behaviours

Returns
this auto-pilot object

◆ arrive()

Vector2D game2dai.steering.AutoPilot.arrive ( )
private

ARRIVE Used internally to calculate the force for this behaviour on the entity that owns this steering behaviour object.

◆ arriveDistance()

double game2dai.steering.AutoPilot.arriveDistance ( )

Get current distance from the owning entity to the arrive target position.

Returns
distance in world units

◆ arriveOff()

AutoPilot game2dai.steering.AutoPilot.arriveOff ( )

Switch off arrive

Returns
this auto-pilot object

◆ arriveOn() [1/5]

AutoPilot game2dai.steering.AutoPilot.arriveOn ( )

Switch on arrive

Returns
this auto-pilot object

◆ arriveOn() [2/5]

AutoPilot game2dai.steering.AutoPilot.arriveOn ( double  x,
double  y 
)

Switch on arrive

Parameters
xthe x position of the target to arrive at
ythe y position of the target to arrive at
Returns
this auto-pilot object

◆ arriveOn() [3/5]

AutoPilot game2dai.steering.AutoPilot.arriveOn ( double  x,
double  y,
int  speed 
)

Switch on arrive and define speed of approach. This should be SBF.SLOW, SBF.NORMAL or SBF.FAST any other value will be result in reverting to default (NORMAL)

Parameters
xthe x position of the target to arrive at
ythe y position of the target to arrive at
speedthe approach rate
Returns
this auto-pilot object

◆ arriveOn() [4/5]

AutoPilot game2dai.steering.AutoPilot.arriveOn ( Vector2D  target)

Switch on arrive.
The approach rate is unchanged by this method.

Parameters
targetthe location to arrive at
Returns
this auto-pilot object

◆ arriveOn() [5/5]

AutoPilot game2dai.steering.AutoPilot.arriveOn ( Vector2D  target,
int  speed 
)

Switch on arrive and define speed of approach. This should be SBF.SLOW, SBF.NORMAL or SBF.FAST any other value will be result in reverting to default (NORMAL)

Parameters
targetthe location to arrive at
speedthe approach rate
Returns
this auto-pilot object

◆ arriveWeight() [1/2]

double game2dai.steering.AutoPilot.arriveWeight ( )

Get the weighting for this behaviour

◆ arriveWeight() [2/2]

AutoPilot game2dai.steering.AutoPilot.arriveWeight ( double  weight)

Set the weight for this behaviour

Parameters
weightthe weighting to be applied to this behaviour.
Returns
this auto-pilot object

◆ bitPos()

static int game2dai.steering.AutoPilot.bitPos ( int  flag)
staticprivate

For a given a bit mask find the position of the least significant set bit.

Parameters
flag
Returns
position of the least significant bit.

◆ calculateForce()

Vector2D game2dai.steering.AutoPilot.calculateForce ( double  deltaTime,
World  world 
)

Calculates (according to selected calculation method) the steering forces from any active behaviours.

Parameters
deltaTimetime since last update in seconds
worldthe game world object
Returns
the calculated steering force as a Vector2D

◆ calculateMethod() [1/2]

int game2dai.steering.AutoPilot.calculateMethod ( )

Find out which method is being used for calculating the steering force.

return the calculation method being used (SBF.WEIGHTED_AVERAGE or SBF.PRIORITIZED).

◆ calculateMethod() [2/2]

AutoPilot game2dai.steering.AutoPilot.calculateMethod ( int  method)

Set which method is to be used for calculating the steering force, options are

SBF.WEIGHTED_AVERAGE (default) or SBF.PRIORITIZED 

any other value will be ignored.

Parameters
methodthe method to use

◆ calculatePrioritised()

Vector2D game2dai.steering.AutoPilot.calculatePrioritised ( )
private

Uses the prioritised weighted average method to calculate the steering force.

Returns
the calculated steering force as a Vector2D

◆ calculatePrioritised_LogForces()

Vector2D game2dai.steering.AutoPilot.calculatePrioritised_LogForces ( )
private

Uses the prioritised weighted average method to calculate the steering force.

Returns
the calculated steering force as a Vector2D

◆ calculateWeightedAverage()

Vector2D game2dai.steering.AutoPilot.calculateWeightedAverage ( )
private

Uses the weighted average method to calculate the steering force.

Returns
the calculated steering force as a Vector2D

◆ calculateWeightedAverage_LogForces()

Vector2D game2dai.steering.AutoPilot.calculateWeightedAverage_LogForces ( )
private

Uses the weighted average method to calculate the steering force and logs the results

Returns
the calculated steering force as a Vector2D

◆ clone()

Object game2dai.steering.AutoPilot.clone ( )

Creates and returns an 'available' (auto-pilot object that can be used in another Vehicle) copy of this object.

◆ cohesion()

Vector2D game2dai.steering.AutoPilot.cohesion ( )
private

COHESION Used internally to calculate the force for this behaviour on the entity that owns this steering behaviour object.

◆ cohesionOff()

AutoPilot game2dai.steering.AutoPilot.cohesionOff ( )

Switch off cohesion

Returns
this auto-pilot object

◆ cohesionOn()

AutoPilot game2dai.steering.AutoPilot.cohesionOn ( )

Switch on cohesion

Returns
this auto-pilot object

◆ cohesionWeight() [1/2]

double game2dai.steering.AutoPilot.cohesionWeight ( )

Get the weighting for this behaviour

◆ cohesionWeight() [2/2]

AutoPilot game2dai.steering.AutoPilot.cohesionWeight ( double  weight)

Set the weight for this behaviour

Parameters
weightthe weighting to be applied to this behaviour.
Returns
this auto-pilot object

◆ createWhiskers()

Vector2D[] game2dai.steering.AutoPilot.createWhiskers ( final int  nbrWhiskers,
final double  whiskerLength,
final double  fov,
final Vector2D  facing,
final Vector2D  origin 
)
private

Used internally by the getFeelers() methods.
Given an origin, a facing direction, a 'field of view' describing the limit of the outer whiskers, a whisker length and the number of whiskers this method returns a vector containing the end positions of a series of whiskers radiating away from the origin and with equal distance between them. (like the spokes of a wheel clipped to a specific segment size)

Parameters
nbrWhiskersnumber of whiskers (>=1)
whiskerLength(the length of the whiskers
fovthe 'field of view'
facingthe vehicle's heading
originthe vehicle's position
Returns
an array of whiskers for wall avoidance

◆ evade()

Vector2D game2dai.steering.AutoPilot.evade ( )
private

EVADE Used internally to calculate the force for this behaviour on the entity that owns this steering behaviour object.

◆ evadeDistance()

double game2dai.steering.AutoPilot.evadeDistance ( )

Get current distance from the owning entity and the moving entity we want to evade.

Returns
distance in world units

◆ evadeFactors()

AutoPilot game2dai.steering.AutoPilot.evadeFactors ( double  fleeDistance)

Set the factors used for evade behaviour.
There is only one factor the flee distance. While the distance between this entity and the evade agent is less than this the entity will move away from the evade agent.

Parameters
fleeDistancethe distance we want to evade by (>0)
Returns
this auto-pilot object

◆ evadeOff()

AutoPilot game2dai.steering.AutoPilot.evadeOff ( )

Switch off evade pursuer

Returns
this auto-pilot object

◆ evadeOn() [1/2]

AutoPilot game2dai.steering.AutoPilot.evadeOn ( )

Switch on evade pursuer

Returns
this auto-pilot object

◆ evadeOn() [2/2]

AutoPilot game2dai.steering.AutoPilot.evadeOn ( MovingEntity  me)

Switch on evade pursuer and specify the entity to avoid.

Parameters
methe entity to evade
Returns
this auto-pilot object

◆ evadeWeight() [1/2]

double game2dai.steering.AutoPilot.evadeWeight ( )

Get the weighting for this behaviour

◆ evadeWeight() [2/2]

AutoPilot game2dai.steering.AutoPilot.evadeWeight ( double  weight)

Set the weight for this behaviour

Parameters
weightthe weighting to be applied to this behaviour.
Returns
this auto-pilot object

◆ flee()

Vector2D game2dai.steering.AutoPilot.flee ( )
private

FLEE Used internally to calculate the force for this behaviour on the entity that owns this steering behaviour object.

◆ fleeDistance()

double game2dai.steering.AutoPilot.fleeDistance ( )

Get current distance from the owning entity to the flee target position.

Returns
distance in world units

◆ fleeFactors()

AutoPilot game2dai.steering.AutoPilot.fleeFactors ( double  fleeDistance)

Set the factors used for flee behaviour agent.
There is only one factor the flee distance. While the distance between this entity and the flee-target is less than this the entity will move away from it.

Parameters
fleeDistancethe distance we want to evade by (>0)
Returns
this auto-pilot object

◆ fleeOff()

AutoPilot game2dai.steering.AutoPilot.fleeOff ( )

Switch off flee

Returns
this auto-pilot object

◆ fleeOn() [1/3]

AutoPilot game2dai.steering.AutoPilot.fleeOn ( )

Switch on flee

Returns
this auto-pilot object

◆ fleeOn() [2/3]

AutoPilot game2dai.steering.AutoPilot.fleeOn ( double  x,
double  y 
)

Switch on flee

Parameters
xthe x position of the location to flee from
ythe y position of the location to flee from
Returns
this auto-pilot object

◆ fleeOn() [3/3]

AutoPilot game2dai.steering.AutoPilot.fleeOn ( Vector2D  location)

Switch on flee

Parameters
locationthe location to flee from
Returns
this auto-pilot object

◆ fleeRadius() [1/2]

double game2dai.steering.AutoPilot.fleeRadius ( )

The effective range of the flee target.

◆ fleeRadius() [2/2]

AutoPilot game2dai.steering.AutoPilot.fleeRadius ( double  fleeRadius)

The flee force applied will be zero if the entity is outside the flee radius

Parameters
fleeRadius
Returns
this auto-pilot object

◆ fleeWeight() [1/2]

double game2dai.steering.AutoPilot.fleeWeight ( )

Get the weighting for this behaviour

◆ fleeWeight() [2/2]

AutoPilot game2dai.steering.AutoPilot.fleeWeight ( double  weight)

Set the weight for this behaviour

Parameters
weightthe weighting to be applied to this behaviour.
Returns
this auto-pilot object

◆ flock()

Vector2D game2dai.steering.AutoPilot.flock ( )
private

FLOCK Used internally to calculate the force for this behaviour on the entity that owns this steering behaviour object.

◆ flockFactors()

AutoPilot game2dai.steering.AutoPilot.flockFactors ( double  neighbourhoodRadius)

Sets the radius for ALL the group behaviours (separation, alignment and cohesion) even if you are using them without flocking.

Parameters
neighbourhoodRadiusthe neighbourhood radius

◆ flockOff()

AutoPilot game2dai.steering.AutoPilot.flockOff ( )

Switch off flock

Returns
this auto-pilot object

◆ flockOn()

AutoPilot game2dai.steering.AutoPilot.flockOn ( )

Switch on flock

Returns
this auto-pilot object

◆ flockWeight() [1/2]

double game2dai.steering.AutoPilot.flockWeight ( )

Get the weighting for this behaviour

◆ flockWeight() [2/2]

AutoPilot game2dai.steering.AutoPilot.flockWeight ( double  weight)

Set the weight for this behaviour

Parameters
weightthe weighting to be applied to this behaviour.
Returns
this auto-pilot object

◆ getFeelers() [1/3]

Vector2D[] game2dai.steering.AutoPilot.getFeelers ( )

FOR INTERNAL USE ONLY
Calculates and returns an array of feelers around the vehicle that owns this steering behaviour.

Returns
array of whisker vectors

◆ getFeelers() [2/3]

Vector2D[] game2dai.steering.AutoPilot.getFeelers ( final Vector2D  facing,
final Vector2D  origin 
)

Calculates and returns an array of feelers around the vehicle that owns this steering behaviour using the specified heading and origin.
This method is called by the Hints class when drawing the whiskers.

Parameters
facingthe facing direction
origin
Returns
array of whisker vectors

◆ getFeelers() [3/3]

Vector2D[] game2dai.steering.AutoPilot.getFeelers ( MovingEntity  me)

Calculates and returns an array of feelers arround the specified moving entity using the whisker details in this steering behaviour.

Parameters
methe moving entity needing whiskers
Returns
array of whisker vectors

◆ getHidingPosition()

Vector2D game2dai.steering.AutoPilot.getHidingPosition ( MovingEntity  me,
Obstacle  ob,
BaseEntity  target 
)
private

Given the position of a hunter, and the position and radius of an obstacle, this method calculates a position DistanceFromBoundary away from its bounding radius and directly opposite the hunter.

◆ getWeight()

double game2dai.steering.AutoPilot.getWeight ( int  behaviour)

Get the weighting for a single behaviour.

Parameters
behaviourshould represent a single behaviour
Returns
weighting of the specified behaviour

◆ hasOwner()

boolean game2dai.steering.AutoPilot.hasOwner ( )

Used to see if this auto-pilot has an owner.

Returns
true if the AP has an owner

◆ hide()

Vector2D game2dai.steering.AutoPilot.hide ( )
private

HIDE Used internally to calculate the force for this behaviour on the entity that owns this steering behaviour object.

◆ hideDistance()

double game2dai.steering.AutoPilot.hideDistance ( )

Get current distance from the owning entity and the moving entity we want are hiding from.

Returns
distance in world units

◆ hideOff()

AutoPilot game2dai.steering.AutoPilot.hideOff ( )

Switch off hide

Returns
this auto-pilot object

◆ hideOn()

AutoPilot game2dai.steering.AutoPilot.hideOn ( )

Switch on hide

Returns
this auto-pilot object

◆ hideWeight() [1/2]

double game2dai.steering.AutoPilot.hideWeight ( )

Get the weighting for this behaviour

◆ hideWeight() [2/2]

AutoPilot game2dai.steering.AutoPilot.hideWeight ( double  weight)

Set the weight for this behaviour

Parameters
weightthe weighting to be applied to this behaviour.
Returns
this auto-pilot object

◆ interpose()

Vector2D game2dai.steering.AutoPilot.interpose ( )
private

INTERPOSE Used internally to calculate the force for this behaviour on the entity that owns this steering behaviour object.

◆ interposeOff()

AutoPilot game2dai.steering.AutoPilot.interposeOff ( )

Switch off interpose

Returns
this auto-pilot object

◆ interposeOn() [1/4]

AutoPilot game2dai.steering.AutoPilot.interposeOn ( )

Switch on interpose

Returns
this auto-pilot object

◆ interposeOn() [2/4]

AutoPilot game2dai.steering.AutoPilot.interposeOn ( MovingEntity  me0,
MovingEntity  me1 
)

Switch on interpose and specify the two moving entities to get between.

Parameters
me0the first mover
me1the second mover
Returns
this auto-pilot object

◆ interposeOn() [3/4]

AutoPilot game2dai.steering.AutoPilot.interposeOn ( MovingEntity  me0,
Vector2D  fixedPos1 
)

Switch on interpose and specify a moving entity and a fixed point in the world to get between.

Parameters
me0the first mover
fixedPos1fixed position in the world.
Returns
this auto-pilot object

◆ interposeOn() [4/4]

AutoPilot game2dai.steering.AutoPilot.interposeOn ( Vector2D  fixedPos0,
Vector2D  fixedPos1 
)

Switch on interpose and specify two fixed points in the world to get between.
This is overkill in this situation, instead use arrive behaviour to the halfway position between the fixed points.

Parameters
fixedPos0first fixed position in the world.
fixedPos1second fixed position in the world.
Returns
this auto-pilot object

◆ interposeWeight() [1/2]

double game2dai.steering.AutoPilot.interposeWeight ( )

Get the weighting for this behaviour

◆ interposeWeight() [2/2]

AutoPilot game2dai.steering.AutoPilot.interposeWeight ( double  weight)

Set the weight for this behaviour

Parameters
weightthe weighting to be applied to this behaviour.
Returns
this auto-pilot object

◆ isAlignmentOn()

boolean game2dai.steering.AutoPilot.isAlignmentOn ( )

Is alignment switched on?

◆ isArriveOn()

boolean game2dai.steering.AutoPilot.isArriveOn ( )

Is arrive switched on?

◆ isCohesionOn()

boolean game2dai.steering.AutoPilot.isCohesionOn ( )

Is cohesion switched on?

◆ isEvadeOn()

boolean game2dai.steering.AutoPilot.isEvadeOn ( )

Is evade switched on?

◆ isFleeOn()

boolean game2dai.steering.AutoPilot.isFleeOn ( )

Is seek switched on?

◆ isFlockOn()

boolean game2dai.steering.AutoPilot.isFlockOn ( )

Is flock switched on?

◆ isHideOn()

boolean game2dai.steering.AutoPilot.isHideOn ( )

Is hide switched on?

◆ isInterposeOn()

boolean game2dai.steering.AutoPilot.isInterposeOn ( )

Is interpose switched on?

◆ isObstacleAvoidOn()

boolean game2dai.steering.AutoPilot.isObstacleAvoidOn ( )

Is wall avoidance switched on?

◆ isOffsetPursuitOn()

boolean game2dai.steering.AutoPilot.isOffsetPursuitOn ( )

Is offsetPursuit switched on?

◆ isPathOn()

boolean game2dai.steering.AutoPilot.isPathOn ( )

Is path switched on?

◆ isPursuitOn()

boolean game2dai.steering.AutoPilot.isPursuitOn ( )

Is pursuit switched on?

◆ isSeekOn()

boolean game2dai.steering.AutoPilot.isSeekOn ( )

Is seek switched on?

◆ isSeparationOn()

boolean game2dai.steering.AutoPilot.isSeparationOn ( )

Is separation switched on?

◆ isWallAvoidOn()

boolean game2dai.steering.AutoPilot.isWallAvoidOn ( )

Is wall avoidance switched on?

◆ isWallAvoidOvalEnvelopeOn()

boolean game2dai.steering.AutoPilot.isWallAvoidOvalEnvelopeOn ( )

If on then the side whiskers are smaller than the front whiskers.

◆ isWanderOn()

boolean game2dai.steering.AutoPilot.isWanderOn ( )

Is wander switched on?

◆ obstacleAvoidance()

Vector2D game2dai.steering.AutoPilot.obstacleAvoidance ( )
private

OBSTACLE AVOIDANCE Used internally to calculate the force for this behaviour on the entity that owns this steering behaviour object.

◆ obstacleAvoidDetectBoxLength() [1/2]

double game2dai.steering.AutoPilot.obstacleAvoidDetectBoxLength ( )

Only provided to enable drawing the box during testing.

Returns
the detection box length

◆ obstacleAvoidDetectBoxLength() [2/2]

AutoPilot game2dai.steering.AutoPilot.obstacleAvoidDetectBoxLength ( double  boxLength)

Set the obstacle avoidance detection box length.

Parameters
boxLengthnew length
Returns
this auto-pilot object

◆ obstacleAvoidFactors()

AutoPilot game2dai.steering.AutoPilot.obstacleAvoidFactors ( double  detectBoxLength)

Set the factors used for obstacle avoidance.
There is only one the detectBoxLength the lager the value the earlier it will see the obstacle.

Parameters
detectBoxLengthdetect box length (>0)
Returns
this auto-pilot object

◆ obstacleAvoidOff()

AutoPilot game2dai.steering.AutoPilot.obstacleAvoidOff ( )

Switch off obstacle avoidance

Returns
this auto-pilot object

◆ obstacleAvoidOn()

AutoPilot game2dai.steering.AutoPilot.obstacleAvoidOn ( )

Switch on obstacle avoidance

Returns
this auto-pilot object

◆ obstacleAvoidWeight() [1/2]

double game2dai.steering.AutoPilot.obstacleAvoidWeight ( )

Get the weighting for this behaviour

◆ obstacleAvoidWeight() [2/2]

AutoPilot game2dai.steering.AutoPilot.obstacleAvoidWeight ( double  weight)

Set the weight for this behaviour

Parameters
weightthe weighting to be applied to this behaviour.
Returns
this auto-pilot object

◆ offsetPursuit()

Vector2D game2dai.steering.AutoPilot.offsetPursuit ( )
private

OFFSET PURSUIT Used internally to calculate the force for this behaviour on the entity that owns this steering behaviour object.

◆ offsetPursuitOff()

AutoPilot game2dai.steering.AutoPilot.offsetPursuitOff ( )

Switch off offsetPursuit

Returns
this auto-pilot object

◆ offsetPursuitOn() [1/2]

AutoPilot game2dai.steering.AutoPilot.offsetPursuitOn ( )

Switch on offsetPursuit

Returns
this auto-pilot object

◆ offsetPursuitOn() [2/2]

AutoPilot game2dai.steering.AutoPilot.offsetPursuitOn ( MovingEntity  me,
Vector2D  offset 
)

Set the target enitiy for offsetPursuit and the offset.

Parameters
me
offset
Returns
this auto-pilot object

◆ offsetPursuitWeight() [1/2]

double game2dai.steering.AutoPilot.offsetPursuitWeight ( )

Get the weighting for this behaviour

◆ offsetPursuitWeight() [2/2]

AutoPilot game2dai.steering.AutoPilot.offsetPursuitWeight ( double  weight)

Set the weight for this behaviour

Parameters
weightthe weighting to be applied to this behaviour.
Returns
this auto-pilot object

◆ pathAddToRoute() [1/4]

AutoPilot game2dai.steering.AutoPilot.pathAddToRoute ( Graph  graph,
GraphNode  dest 
)

Calculate and add the route from the end of the existing path (or the nearest node if there is no existing path) to the dest Node. The path calculation will use A* with crow's flight heuristic when calculating the route.
The instruction is ignored if the graph or destination node does note exist.

Parameters
graph
dest

◆ pathAddToRoute() [2/4]

AutoPilot game2dai.steering.AutoPilot.pathAddToRoute ( List< GraphNode route)

Add the route to the end of the existing path. Do nothing if the parameter is null.

Parameters
routethe path to add

◆ pathAddToRoute() [3/4]

AutoPilot game2dai.steering.AutoPilot.pathAddToRoute ( Vector2D  waypoint)

Add the waypoint to the end of the existing path and switch path following on. Do nothing if the parameter is null or empty.

Parameters
waypointadd a single waypoint to the route
Returns
this auto-pilot object

◆ pathAddToRoute() [4/4]

AutoPilot game2dai.steering.AutoPilot.pathAddToRoute ( Vector2D[]  route)

Add the route to the end of the existing path and switch path following on. Do nothing if the parameter is null or empty.

Parameters
routethe path to follow
Returns
this auto-pilot object

◆ pathFactors()

AutoPilot game2dai.steering.AutoPilot.pathFactors ( Object  seekDist,
Object  arriveDist 
)
Parameters
seekDistdistance to way-point when considered reached
arriveDistdistance to destination when considered reached
Returns
this auto-pilot object

◆ pathFollow()

Vector2D game2dai.steering.AutoPilot.pathFollow ( )
private

PATH Given a series of Vector2Ds, this method produces a force that will move the agent along the waypoints in order. The agent uses the 'Seek' behaviour to move to the next waypoint - unless it is the last

waypoint, in which case it 'Arrives'

◆ pathNextNode()

GraphNode game2dai.steering.AutoPilot.pathNextNode ( )

Get the node the entity is currently moving towards. If there is no path defined or the entity has reached the end of its last path the method returns null.

Returns
current path target or null if none

◆ pathOff()

AutoPilot game2dai.steering.AutoPilot.pathOff ( )

Switch off path

Returns
this auto-pilot object

◆ pathOn()

AutoPilot game2dai.steering.AutoPilot.pathOn ( )

Switch on path

Returns
this auto-pilot object

◆ pathRoute()

LinkedList< GraphNode > game2dai.steering.AutoPilot.pathRoute ( )

Get the path the entity is following

Returns
linked list of nodes in the current path

◆ pathRouteLength()

int game2dai.steering.AutoPilot.pathRouteLength ( )

Get the number of way-points left on the current route

◆ pathSetRoute() [1/2]

AutoPilot game2dai.steering.AutoPilot.pathSetRoute ( List< GraphNode route)

Set the path the entity should follow. Ignore if route is null or has less than 2 locations.

Parameters
routethe path to follow
Returns
this auto-pilot object

◆ pathSetRoute() [2/2]

AutoPilot game2dai.steering.AutoPilot.pathSetRoute ( Vector2D[]  route)

Set the path the entity should follow. Ignore if route is null or has less than 2 nodes.

Parameters
routethe path to follow
Returns
this auto-pilot object

◆ pathWeight() [1/2]

double game2dai.steering.AutoPilot.pathWeight ( )

Get the weighting for this behaviour

◆ pathWeight() [2/2]

AutoPilot game2dai.steering.AutoPilot.pathWeight ( double  weight)

Set the weight for this behaviour

Parameters
weightthe weighting to be applied to this behaviour.
Returns
this auto-pilot object

◆ pursuit() [1/2]

Vector2D game2dai.steering.AutoPilot.pursuit ( )
private

PURSUIT Used internally to calculate the force for this behaviour on the entity that owns this steering behaviour object.

◆ pursuit() [2/2]

Vector2D game2dai.steering.AutoPilot.pursuit ( MovingEntity  me,
MovingEntity  toPursue 
)
protected

PURSUIT Seek to the agent's predicted position based on velocities and estimated time to intercept

◆ pursuitDistance()

double game2dai.steering.AutoPilot.pursuitDistance ( )

Get current distance from the owning entity and the moving entity we want are pursuing.

Returns
distance in world units

◆ pursuitOff()

AutoPilot game2dai.steering.AutoPilot.pursuitOff ( )

Switch off pursuit pursuer

Returns
this auto-pilot object

◆ pursuitOn() [1/2]

AutoPilot game2dai.steering.AutoPilot.pursuitOn ( )

Switch on pursuit pursuer

Returns
this auto-pilot object

◆ pursuitOn() [2/2]

AutoPilot game2dai.steering.AutoPilot.pursuitOn ( MovingEntity  me)

Switch on pursuit and specify the entity to persue.

Parameters
methe entity to pursuit
Returns
this auto-pilot object

◆ pursuitWeight() [1/2]

double game2dai.steering.AutoPilot.pursuitWeight ( )

Get the weighting for this behaviour

◆ pursuitWeight() [2/2]

AutoPilot game2dai.steering.AutoPilot.pursuitWeight ( double  weight)

Set the weight for this behaviour

Parameters
weightthe weighting to be applied to this behaviour.
Returns
this auto-pilot object

◆ seek()

Vector2D game2dai.steering.AutoPilot.seek ( )
private

SEEK Used internally to calculate the force for this behaviour on the entity that owns this steering behaviour object.

◆ seekDistance()

double game2dai.steering.AutoPilot.seekDistance ( )

Get current distance from the owning entity to the seek target position.

Returns
distance in world units

◆ seekOff()

AutoPilot game2dai.steering.AutoPilot.seekOff ( )

Switch off seek

Returns
this auto-pilot object

◆ seekOn() [1/3]

AutoPilot game2dai.steering.AutoPilot.seekOn ( )

Switch on seek

Returns
this auto-pilot object

◆ seekOn() [2/3]

AutoPilot game2dai.steering.AutoPilot.seekOn ( double  x,
double  y 
)

Switch on seek

Parameters
xthe x position of the target to seek
ythe y position of the target to seek
Returns
this auto-pilot object

◆ seekOn() [3/3]

AutoPilot game2dai.steering.AutoPilot.seekOn ( Vector2D  target)

Switch on seek

Parameters
targetthe location to seek
Returns
this auto-pilot object

◆ seekWeight() [1/2]

double game2dai.steering.AutoPilot.seekWeight ( )

Get the weighting for this behaviour

◆ seekWeight() [2/2]

AutoPilot game2dai.steering.AutoPilot.seekWeight ( double  weight)

Set the weight for this behaviour

Parameters
weightthe weighting to be applied to this behaviour.
Returns
this auto-pilot object

◆ separation()

Vector2D game2dai.steering.AutoPilot.separation ( )
private

SEPARATION Used internally to calculate the force for this behaviour on the entity that owns this steering behaviour object.

◆ separationOff()

AutoPilot game2dai.steering.AutoPilot.separationOff ( )

Switch off separation

Returns
this auto-pilot object

◆ separationOn()

AutoPilot game2dai.steering.AutoPilot.separationOn ( )

Switch on separation

Returns
this auto-pilot object

◆ separationWeight() [1/2]

double game2dai.steering.AutoPilot.separationWeight ( )

Get the weighting for this behaviour

◆ separationWeight() [2/2]

AutoPilot game2dai.steering.AutoPilot.separationWeight ( double  weight)

Set the weight for this behaviour

Parameters
weightthe weighting to be applied to this behaviour.
Returns
this auto-pilot object

◆ setOwner()

AutoPilot game2dai.steering.AutoPilot.setOwner ( final Vehicle  vehicle)

DO NOT USE THIS METHOD
This method is for sole use by the Vehicle class when a steering behaviour is added.

Parameters
vehicle

◆ toString()

String game2dai.steering.AutoPilot.toString ( )

This method provides a String object that describes the active behaviours and their details. This is useful when debugging.

◆ wallAvoidance()

Vector2D game2dai.steering.AutoPilot.wallAvoidance ( )
private

WALL AVOIDANCE Used internally to calculate the force for this behaviour on the entity that owns this steering behaviour object.

◆ wallAvoidFactors()

AutoPilot game2dai.steering.AutoPilot.wallAvoidFactors ( Object  nbrWhiskers,
Object  whiskerLength,
Object  fov,
Boolean  shortOnSide 
)

Set some or all of the factors used for wall avoidance.
Only provide values for the factors you want to set, pass 'null' for any factor that is to be unchanged.
Where appropriate validation will be applied to the value passed and if invalid (eg out of permitted range) will be silently ignored (no warning message) and the factor will remain unchanged.

Parameters
nbrWhiskersthe number of feelers to use (>0)
whiskerLengththe length of the feelers (>0)
fovthe arc angle (radians) covered by the feeler array (>0 and <= 2Pi
shortOnSideif true then the side feelers are shorter than front facing feelers else all feelers are the same length
Returns
this auto-pilot object

◆ wallAvoidFOV()

double game2dai.steering.AutoPilot.wallAvoidFOV ( )

Get the angle covered by the whiskers

◆ wallAvoidNbrWhiskers()

int game2dai.steering.AutoPilot.wallAvoidNbrWhiskers ( )

Get the number of whiskers used.

◆ wallAvoidOff()

AutoPilot game2dai.steering.AutoPilot.wallAvoidOff ( )

Switch off wall avoidance

Returns
this auto-pilot object

◆ wallAvoidOn()

AutoPilot game2dai.steering.AutoPilot.wallAvoidOn ( )

Switch on wall avoidance

Returns
this auto-pilot object

◆ wallAvoidWeight() [1/2]

double game2dai.steering.AutoPilot.wallAvoidWeight ( )

Get the weighting for this behaviour

◆ wallAvoidWeight() [2/2]

AutoPilot game2dai.steering.AutoPilot.wallAvoidWeight ( double  weight)

Set the weight for this behaviour

Parameters
weightthe weighting to be applied to this behaviour.
Returns
this auto-pilot object

◆ wallAvoidWhiskerLength()

double game2dai.steering.AutoPilot.wallAvoidWhiskerLength ( )

Get the length of the whiskers

Returns
the whiskerLength

◆ wander()

Vector2D game2dai.steering.AutoPilot.wander ( )
private

WANDER Used internally to calculate the wander force

◆ wanderAngle()

double game2dai.steering.AutoPilot.wanderAngle ( )

Gets the current angle in the wander radius circle

Returns
the wander angle

◆ wanderAngleJitter()

double game2dai.steering.AutoPilot.wanderAngleJitter ( )

Gets the maximum amount of jitter allowed per second

◆ wanderDist()

double game2dai.steering.AutoPilot.wanderDist ( )
Returns
the wanderDist

◆ wanderFactors()

AutoPilot game2dai.steering.AutoPilot.wanderFactors ( Object  dist,
Object  radius,
Object  jitter 
)

Set some or all of the factors used for wander behaviour.
Only provide values for the factors you want to set, pass 'null' for any factor that is to be unchanged.
Where appropriate validation will be applied to the value passed and if invalid (eg out of permitted range) will be silently ignored (no warning message) and the factor will remain unchanged.

Parameters
dist
radius
jitter
Returns
this auto-pilot object

◆ wanderOff()

AutoPilot game2dai.steering.AutoPilot.wanderOff ( )

Switch off wander

Returns
this auto-pilot object

◆ wanderOn()

AutoPilot game2dai.steering.AutoPilot.wanderOn ( )

Switch on wander

Returns
this auto-pilot object

◆ wanderRadius()

double game2dai.steering.AutoPilot.wanderRadius ( )
Returns
the wanderRadius

◆ wanderWeight() [1/2]

double game2dai.steering.AutoPilot.wanderWeight ( )

Get the weighting for this behaviour

◆ wanderWeight() [2/2]

AutoPilot game2dai.steering.AutoPilot.wanderWeight ( double  weight)

Set the weight for this behaviour

Parameters
weightthe weighting to be applied to this behaviour.
Returns
this auto-pilot object

Member Data Documentation

◆ agents

MovingEntity [] game2dai.steering.AutoPilot.agents = new MovingEntity[NBR_AGENT_ARRAY]
private

the first 2 are used for the interpose AGENT0, AGENT1, AGENT_TO_PURSUE, AGENT_TO_EVADE

◆ bnames

String [] game2dai.steering.AutoPilot.bnames
staticprivate
Initial value:
= new String[] {
" wall-avoid",
" obstacle-avoid",
" evade ",
" flee ",
" separation ",
" alignment ",
" cohesion ",
" seek ",
" arrive ",
" wander ",
" pursuit ",
" offset-pursuit",
" interpose ",
" hide ",
" path ",
" flock "
}

◆ weightings

double [] game2dai.steering.AutoPilot.weightings
private
Initial value:
= new double[] {
220.0,
80.0,
1.0,
20.0,
1.0,
4.0,
15.0,
20.0,
20.0,
5.0,
100.0,
10.0,
10.0,
10.0,
20.0,
1.0
}

Default values for steering behaviour objects.


The documentation for this class was generated from the following file: