Delivery Service Agent

This tutorial assumes you are familiar with setting up a point-to-point delivery agent.

Service agents are intended to be used where the clients are not necessarily known at design time and may change over time. The example used in this tutorial is a military resupply fleet that will be configured with a local source of products and will automatically resupply any local fleet with a military designation.

Open the faction agent panel and click the add  icon and choose a name for the new agent. A blank agent will now appear in the agent panel ready for configuration

Variables

For this agent, a fixed source of products is used. Open the agent and create a new variable SOURCE of type Fleet and bind it to an appropriate source.

Behaviours

From the behaviours tab and create new Collect and Idle behaviours in the same manner as for the point-to-point delivery agent.

Service

Change to the services tab and add a new service Deliver. A service is bound to a specific system, in this case we can leave it at the default local, which means the location of the fleet this agent is currently bound to. The task should be changed to Export( client ), where client represents a variable that can be bound to any fleet in the system that matches service preconditions (except the fleet the agent itself is bound to). Enter appropriate values for utility and switching cost as before.

The precondition for the service is more complicated than for the point-to-point agent. It is undesirable for the service to consider its product source as a potential client (leading to a delivery loop). We also want the service to only serve military fleets, otherwise it might become distracted delivering to regular fleets that have an alternate supply chain already set up. The precondition is therefore made up of three separate predicates that form a conjunction (logical and).

If you desire a disjunction (logical or) then add a whole new condition, which makes a behaviour or service applicable if any of the preconditions evaluates to true.

Now link the agent to the desired fleet, and enable all services and behaviours. When an applicable client is found a new behaviour will be dynamically created tailored to that client and visible in the behaviours panel. Multiple such behaviours can exist and will compete for the agent’s attention

Preconditions for services are particularly important to avoid agents serving unintended clients. If setting up a generic product delivery agent intended to serve construction sites across the system then it is worth including the predicate ¬IsMobile( client ) to avoid the supply fleet chasing other transport fleets around the system to top up their supplies.