jadex.micro.examples.fireflies.FireflyAgent Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jadex-applications-micro Show documentation
Show all versions of jadex-applications-micro Show documentation
The Jadex micro applications package contains several example applications, benchmarks and testcases using micro agents.
package jadex.micro.examples.fireflies;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import jadex.application.EnvironmentService;
import jadex.bridge.IComponentStep;
import jadex.bridge.IInternalAccess;
import jadex.bridge.component.IExecutionFeature;
import jadex.commons.IFilter;
import jadex.commons.future.ExceptionDelegationResultListener;
import jadex.commons.future.Future;
import jadex.commons.future.IFuture;
import jadex.extension.envsupport.environment.ISpaceAction;
import jadex.extension.envsupport.environment.ISpaceObject;
import jadex.extension.envsupport.environment.space2d.ContinuousSpace2D;
import jadex.extension.envsupport.environment.space2d.Space2D;
import jadex.extension.envsupport.math.IVector2;
import jadex.extension.envsupport.math.Vector1Int;
import jadex.extension.envsupport.math.Vector2Double;
import jadex.micro.annotation.Agent;
import jadex.micro.annotation.AgentBody;
import jadex.micro.annotation.AgentCreated;
/**
* The firefly agent.
*/
@Agent
public class FireflyAgent
{
/** The agent. */
@Agent
protected IInternalAccess agent;
//-------- methods --------
/**
* Init method.
*/
@AgentCreated
public void agentCreated()
{
System.out.println("firefly created: "+agent.getComponentIdentifier());
}
/**
* Execute an agent step.
*/
@AgentBody
public IFuture executeBody()
{
System.out.println("firefly body: "+agent.getComponentIdentifier());
final Future ret = new Future();
EnvironmentService.getSpace(agent, "mygc2dspace")
.addResultListener(new ExceptionDelegationResultListener