
jadex.bdi.examples.spaceworld3d.producer.ProduceOrePlan Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jadex-applications-bdi Show documentation
Show all versions of jadex-applications-bdi Show documentation
The Jadex BDI applications package contain
several example applications, benchmarks and
testcases using BDI agents.
The newest version!
package jadex.bdi.examples.spaceworld3d.producer;
import jadex.bdi.planlib.PlanFinishedTaskCondition;
import jadex.bdi.runtime.IGoal;
import jadex.bdi.runtime.Plan;
import jadex.extension.envsupport.environment.AbstractTask;
import jadex.extension.envsupport.environment.IEnvironmentSpace;
import jadex.extension.envsupport.environment.ISpaceObject;
import jadex.extension.envsupport.environment.space3d.Space3D;
import java.util.HashMap;
import java.util.Map;
/**
* Inform the sentry agent about a new target.
*/
public class ProduceOrePlan extends Plan
{
/**
* The plan body.
*/
public void body()
{
ISpaceObject target = (ISpaceObject)getParameter("target").getValue();
// Move to the target.
IGoal go_target = createGoal("move.move_dest");
go_target.getParameter("destination").setValue(target.getProperty(Space3D.PROPERTY_POSITION));
dispatchSubgoalAndWait(go_target);
// Produce ore at the target.
ISpaceObject myself = (ISpaceObject)getBeliefbase().getBelief("move.myself").getFact();
SyncResultListener res = new SyncResultListener();
Map props = new HashMap();
props.put(ProduceOreTask.PROPERTY_TARGET, target);
props.put(AbstractTask.PROPERTY_CONDITION, new PlanFinishedTaskCondition(getPlanElement()));
IEnvironmentSpace space = (IEnvironmentSpace)getBeliefbase().getBelief("move.environment").getFact();
Object taskid = space.createObjectTask(ProduceOreTask.PROPERTY_TYPENAME, props, myself.getId());
space.addTaskListener(taskid, myself.getId(), res);
res.waitForResult();
// System.out.println("Produced ore at target: "+getAgentName()+", "+ore+" ore produced.");
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy