
jadex.bdi.examples.marsworld_classic.movement.MoveToLocationPlan 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.marsworld_classic.movement;
import jadex.bdi.examples.marsworld_classic.AgentInfo;
import jadex.bdi.examples.marsworld_classic.Environment;
import jadex.bdi.examples.marsworld_classic.Location;
import jadex.bdi.runtime.Plan;
/**
* The move to a location plan.
*/
public class MoveToLocationPlan extends Plan
{
//-------- constructors --------
/**
* Create a new plan.
*/
public MoveToLocationPlan()
{
//getLogger().info("Created: "+this);
}
//-------- methods --------
/**
* The plan body.
*/
public void body()
{
Environment env = (Environment)getBeliefbase().getBelief("environment").getFact();
// Retrieve the target destination.
Location myloc = (Location)getBeliefbase().getBelief("my_location").getFact();
Location dest = (Location)getParameter("destination").getValue();
//long time = getTime();
//System.out.println("move: "+myloc+" "+dest);
while(!myloc.isNear(dest))
{
// Calculate the new position offset.
//long newtime = getTime();
double speed = ((Double)getBeliefbase().getBelief("my_speed").getFact()).doubleValue();
double d = myloc.getDistance(dest);
double r = speed*0.00001*100;//(newtime-time);
double dx = dest.getX()-myloc.getX();
double dy = dest.getY()-myloc.getY();
//time = newtime;
// When radius greater than distance, just move a step.
double rx = r
© 2015 - 2025 Weber Informatics LLC | Privacy Policy