Now that we have a newly created geographical graph, let's see how we can make agent move into it in a realistic way.
To do so, we will use, as is, the previously implemented ShuttleBehavior. Actually, because the description of such a behaviour does not depend on the nature of the nodes, it was important to make it natively usable with any kind of nodes.
Our buildAgents
function will use the following provided classes :
GeoAgent
: AMovingAgent
with aGeoAgentBody
GeoAgentBody
: An agent body with a geographical positionBasicGeoMover
: A basicGeoMover
implementation that make an agent moves realistically in the geographical environment at each ticks, according to its speed in m/s.
For more information, do not hesitate to check the corresponding Javadocs.
So, for now, let's build one agent, that makes round-trips between nodes 1 and 3 thanks to the ShuttleBehavior
:
@Override
public Collection<GeoAgent> buildAgents(SmartGovContext context) {
ArrayList<GeoAgent> agents = new ArrayList<>();
/*
* A basic geographical mover that allows agent to move
* along arcs.
*/
BasicGeoMover mover = new BasicGeoMover();
GeoAgentBody agentBody = new GeoAgentBody(mover);
// default 1m/s speed
agentBody.setSpeed(1);
agents.add(new GeoAgent(
"1",
agentBody,
new ShuttleBehavior(
agentBody,
context.nodes.get("1"),
context.nodes.get("3"),
context)
));
return agents;
}
You can now run a simulation to ensure everything is ok.