All Downloads are FREE. Search and download functionalities are using the official Maven repository.

jadex.bdi.examples.hunterprey.ldahunter.potentialfield.CreatureModel Maven / Gradle / Ivy

Go to download

The Jadex BDI applications package contain several example applications, benchmarks and testcases using BDI agents.

There is a newer version: 2.4
Show newest version
/*
 * Created on Sep 17, 2004
 */
package jadex.bdi.examples.hunterprey.ldahunter.potentialfield;

import jadex.extension.envsupport.environment.ISpaceObject;


/**
 * 
 */
public class CreatureModel
{
	final int w;
	final int h;
	final ISpaceObject c;

	/**
	 * @param creature
	 * @param w
	 * @param h
	 */
	public CreatureModel(ISpaceObject creature, final int w, final int h)
	{
		this.w = w;
		this.h = h;
		this.c = creature;
	}

	/**
	 * x last x of creature
	 */
	public int x;
	/**
	 * y last y of creature
	 */
	public int y;
	/**
	 * round last round updated
	 */
	public int round;


	/**
	 * @param px
	 * @param py
	 * @param r > round
	 * @return the probability the creature is in px,py in round r
	 */
	public double getProbability(int px, int py, int r)
	{
		final int dr = r-round;
		int d = 1+dr-Math.abs(x-px)%w-Math.abs(y-py)%h;
		d = d>0? d: 0; // cut
		final int dr2 = dr*dr;
		return 3.0*d/(dr2*dr*2+dr2*6+dr*7+3);
	}

	/**
	 * @param x2
	 * @param y2
	 * @param r
	 */
	public void update(int x2, int y2, int r)
	{
		x = x2;
		y = y2;
		round = r;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy