
jadex.bdi.examples.blackjack.player.strategies.StochasticTable 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.strategies;
import jadex.bdi.examples.blackjack.Card;
import jadex.bdi.examples.blackjack.CardSet;
/**
* The stochastic table strategy.
*/
public class StochasticTable extends AbstractStrategy
{
//-------- constructors --------
/**
* Create a new strategy.
* @param name The name.
*/
public StochasticTable(String name)
{
super(name);
}
//-------- methods --------
/**
* Calculate how much to bet, given the account value.
* @param account
* @return The bet.
*/
public int makeBet(int account)
{
return 10;
}
/**
* Decide if to draw another card.
* @param playercards
* @param dealercard
* @return True, if the player wants to draw a card.
*/
public boolean drawCard(Card[] playercards, Card dealercard)
{
boolean playerHasAce = false;
boolean drawCard = false;
int playerCardsValue = CardSet.calculateDeckValue(playercards);
int dealerCardValue = CardSet.calculateDeckValue(new Card[]{dealercard});
for(int i = 0; i8))
drawCard = true;
}
else
{
if(playerCardsValue<12)
drawCard = true;
else if((playerCardsValue==12) &&
((dealerCardValue<4) || (dealerCardValue>6)))
drawCard = true;
else if((playerCardsValue>12) && (playerCardsValue<17) &&
(dealerCardValue<7))
drawCard = true;
}
return drawCard;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy