
jadex.bdi.examples.hunterprey_classic.environment.SimulationTickerPlan 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.hunterprey_classic.environment;
import jadex.bdi.examples.hunterprey_classic.Creature;
import jadex.bdi.examples.hunterprey_classic.CurrentVision;
import jadex.bdi.examples.hunterprey_classic.Vision;
import jadex.bdi.runtime.IMessageEvent;
import jadex.bdi.runtime.Plan;
import jadex.bridge.MessageFailureException;
import jadex.bridge.fipa.SFipa;
/**
* The simulation ticker plan has the task to trigger
* the environment whenever a simulation step needs to be done.
*/
/* @requires belief environment
* @requires belief roundtime
*/
public class SimulationTickerPlan extends Plan
{
//-------- methods --------
/**
* The body method.
*/
public void body()
{
Environment env = (Environment)getBeliefbase().getBelief("environment").getFact();
while(true)
{
// System.out.println("before wait");
waitFor(((Long)getBeliefbase().getBelief("roundtime").getFact()).longValue());
// System.out.println("after wait");
env.executeStep();
// System.out.println("Actual tick cnt: "+getBeliefbase().getBelief("???").getFact("tickcnt"));
// Dispatch new visions.
Creature[] creatures = env.getCreatures();
// System.out.println("Knows creatures: "+creatures.length);
for(int i=0; i
© 2015 - 2025 Weber Informatics LLC | Privacy Policy