/* * RandomSupportStrategy.java * * Created on April 17, 2004, 6:22 PM */ package simulations.core.strategy.decisionSupportStrategy; import java.util.ArrayList; import simulations.core.Player; /** * This class describes a decision support strategy. It ask yes/no with * a probability of 0.5 but say always no to an attack versus itself * @author tom */ public class RandomSupportStrategy extends DecisionSupportStrategy { /** Creates a new instance of RandomSupportStrategy */ public RandomSupportStrategy() { super(); name="RandomSupportStrategy"; memoryParam=false; abr="16"; } /** return true if the player will support the attack. * @return return true if the player will support the attack. * @param player The owner of the strategy * @param attackingPlayer The attacking player * @param attackedPlayer The attacked player * @param playerList The list of remaining players */ public boolean supportAttack(Player player, Player attackingPlayer, Player attackedPlayer, ArrayList playerList) { if (player.equals(attackedPlayer)) { // don't accept to support an attack on himself return false; } if (randomGenerator.nextInt(2)==0) { return true; } else { return false; } } /** * This method is called by the judge after the decision of players to attack and to ask supports * to inform the strategy * @param player The owner of the strategy * @param attacksList The list of attacks **/ public void updateAttacksInfos(Player player, ArrayList attacksList) { } /** This method is called by the judge to inform players of the last turn * @param turn The turn * @param player The owner of the strategy * @param remainingPlayers The list of the remaining players */ public void updateLastTurn(simulations.core.history.Turn turn, simulations.core.Player player, java.util.ArrayList remainingPlayers) { } /** return the description of this decision support strategy * @return return the description of this decision support strategy **/ public String getDescription() { return "Decision support strategy :\n"+ "I accept randomly with a probabilty of 0.5\n"+ "but I never accept an attack versus myself\n"; } }