jadex.micro.examples.heatbugs.HeatbugAgent 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.heatbugs;
import java.util.Collection;
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.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.Grid2D;
import jadex.extension.envsupport.environment.space2d.Space2D;
import jadex.extension.envsupport.math.IVector2;
import jadex.extension.envsupport.math.Vector1Int;
import jadex.micro.annotation.Agent;
import jadex.micro.annotation.AgentBody;
/**
* The heatbug agent.
*/
@Agent
public class HeatbugAgent
{
//-------- attributes --------
/** The agent. */
@Agent
protected IInternalAccess agent;
/** The probability of a random move. */
protected double randomchance;
/** The desired temperature. */
protected double ideal_temp;
/** The current temperature. */
protected double mytemp;
/** The current unhappiness. */
protected double unhappiness;
//-------- methods --------
/**
* Execute an agent step.
*/
@AgentBody
public IFuture executeBody()
{
final Future ret = new Future();
EnvironmentService.getSpace(agent, "mygc2dspace")
.addResultListener(new ExceptionDelegationResultListener