new Agent(lat_lng, options, agentmap)
Constructor for the Agent class, using Leaflet class system.
Parameters:
Name | Type | Description |
---|---|---|
lat_lng |
LatLng | A pair of coordinates to place the agent at. |
options |
Object | An array of options for the agent, namely its layer. |
agentmap |
Agentmap | The agentmap instance in which the agent exists. |
Properties:
Name | Type | Attributes | Default | Description | ||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
feature.AgentMap_id |
number | The agent's instance id, so it can be accessed from inside the Leaflet layer. To avoid putting the actual instance inside the feature object. | ||||||||||||||||||||||||||||||||||||||||||||||
agentmap |
Agentmap | The agentmap instance in which the agent exists. | ||||||||||||||||||||||||||||||||||||||||||||||
place |
Place | A place object specifying where the agent is currently at. | ||||||||||||||||||||||||||||||||||||||||||||||
steps_made |
number |
<optional> |
0 | The number of steps the agent has moved since the beginning. | ||||||||||||||||||||||||||||||||||||||||||||
this.trip |
Object | Properties detailing information about the agent's trip that change sometimes, but needs to be accessed by future updates.
Properties
|
||||||||||||||||||||||||||||||||||||||||||||||
controller |
function |
<nullable> |
User-defined function to be called on each update (each tick). | |||||||||||||||||||||||||||||||||||||||||||||
fine_controller |
function |
<nullable> |
User-defined function to be called before & after each movemnt (on each step an agent performs during a tick). |
Methods
(static) checkSpeed(speed)
Check whether a given speed is greater than the minimum.
Parameters:
Name | Type | Description |
---|---|---|
speed |
number | A number representing the speed of an agent in meters per second. |
(static) increaseSpeed(magnitude)
Increase the speed the agent moves along its currently scheduled path by a constant.
Parameters:
Name | Type | Description |
---|---|---|
magnitude |
number | The number to add to the agent's scheduled speed. All scheduled speeds must be >= .1 |
(static) moveIt()
Make the agent proceed along its trip.
(static) multiplySpeed(multiplier)
Multiply the speed the agent moves along its currently scheduled path by a constant.
Parameters:
Name | Type | Description |
---|---|---|
multiplier |
number | The number to multiply the agent's scheduled speed by. All scheduled speeds must be >= .1. |
(static) pauseTrip()
Stop the agent where it is along its trip.
(static) resetTrip()
Reset all the properties of its trip, but don't change whether it's allowed to be traveling or not.
(static) resumeTrip()
Have the agent continue from where it was left off along its trip.
(static) setSpeed(speed)
Set a new, constant speed for the agent to move along its currently scheduled path.
Parameters:
Name | Type | Description |
---|---|---|
speed |
number | The speed (in meters per tick) that the agent should move. Must be >= .1. |
(static) setTravelToPlace(goal_lat_lng, goal_place, speedopt, move_directlyopt, replace_tripopt)
Schedule the agent to travel directly from any point (e.g. of a street or unit) to a point (e.g. of another street or unit).
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
goal_lat_lng |
LatLng | The point within the place to which the agent is to travel. | ||
goal_place |
Place | The place to which the agent will travel. | ||
speed |
number |
<optional> |
1 | The speed in meters per tick that the agent should try to travel. Must be >= .1. |
move_directly |
Boolean |
<optional> |
false | Whether to ignore the streets & roads and move directly to the goal. |
replace_trip |
Boolean |
<optional> |
false | Whether to empty the currently scheduled path and replace it with this new trip; false by default (the new trip is simply appended to the current scheduled path). |
(static) startTrip()
Set the agent up to start traveling along the path specified in the agent's trip..