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

jadex.bdi.examples.blackjack.dealer.PropagateGameStatePlan Maven / Gradle / Ivy

Go to download

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

The newest version!
package jadex.bdi.examples.blackjack.dealer;

import jadex.bdi.examples.blackjack.GameState;
import jadex.bdi.examples.blackjack.Player;
import jadex.bdi.runtime.IMessageEvent;
import jadex.bdi.runtime.IParameterSet;
import jadex.bdi.runtime.Plan;
import jadex.bridge.fipa.SFipa;
import jadex.commons.SUtil;

import java.util.List;

/**
 *  Updates the belief "gamestate" and propage the gamestate.
 */
public class PropagateGameStatePlan extends Plan
{
	/**
	 * The body method is called on the
	 * instatiated plan instance from the scheduler.
	 */
	public void body()
	{
		GameState gs = (GameState)getBeliefbase().getBelief("gamestate").getFact();
		Player me = (Player)getBeliefbase().getBelief("myself").getFact();

		if(gs.getDealer()==null)
			gs.setDealer(me);

		List olds = SUtil.arrayToList(gs.getPlayers());
		Player[] news = (Player[])getBeliefbase().getBeliefSet("players").getFacts();
		for(int i=0; i0)
		{
			IMessageEvent	inform	= createMessageEvent("inform_game_state");
			inform.getParameter(SFipa.CONTENT).setValue(gs);
			IParameterSet rec = inform.getParameterSet("receivers");
			for(int i=0; i




© 2015 - 2025 Weber Informatics LLC | Privacy Policy