
jadex.bdi.examples.blackjack.player.UpdateGameStatePlan 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.blackjack.player;
import jadex.bdi.examples.blackjack.GameState;
import jadex.bdi.examples.blackjack.Player;
import jadex.bdi.runtime.Plan;
import jadex.commons.SUtil;
import java.util.List;
/**
* Update the game state.
*/
public class UpdateGameStatePlan extends Plan
{
/**
* The body method is called on the
* instatiated plan instance from the scheduler.
*/
public void body()
{
GameState gs = (GameState)getParameter("gamestate").getValue();
GameState gsold = (GameState)getBeliefbase().getBelief("gamestate").getFact();
// System.out.println("Game state new: "+gs);
// System.out.println("Game state old: "+gsold);
Player me = (Player)getBeliefbase().getBelief("myself").getFact();
if(gs.getDealer()==null || !gs.getDealer().equals(gsold.getDealer()))
{
gsold.setDealer(gs.getDealer());
}
else
{
gsold.updateDealer(gs.getDealer());
}
List olds = SUtil.arrayToList(gsold.getPlayers());
Player[] news = gs.getPlayers();
for(int i=0; i© 2015 - 2025 Weber Informatics LLC | Privacy Policy