/* * AcceptPlayersDontAttackMe.java * * Created on April 23, 2004, 2:09 AM */ package simulations.core.strategy.decisionSupportStrategy; import simulations.core.Player; import java.util.ArrayList; import java.util.Iterator; import simulations.core.history.Turn; import simulations.core.history.PlayerTurn; import simulations.core.strategy.PlayerIntElement; /** * This class describes a decision support strategy that accept only * if the asking player never attacked me directly * @author tom */ public class AcceptPlayersDontAttackMeStrategy extends DecisionSupportStrategy { private ArrayList notAcceptList; private boolean first; /** Creates a new instance of AcceptPlayersDontAttackMe */ public AcceptPlayersDontAttackMeStrategy() { super(); name="AcceptPlayersDontAttackMeStrategy"; notAcceptList = new ArrayList(); memoryParam=true; abr="6"; } /** 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 if asking player have never\n"+ "attacked me directly memory="+memory+"\n"; } /** * return true if the player will support the attack. * @return return true if the player will support the attack. * @param playerList The remaining players list * @param player The owner of the strategy * @param attackingPlayer The attacking player * @param attackedPlayer The attacked player */ public boolean supportAttack(Player player, Player attackingPlayer, Player attackedPlayer, ArrayList playerList) { if (simulations.SimulationParameters.debug) { System.out.println("notAcceptList = "+notAcceptList.toString()); } if (attackedPlayer.equals(player)) { if (simulations.SimulationParameters.debug) { System.out.println("Je ne m'attaque pas"); } return false; } if (containsPlayer(attackingPlayer)) { if (simulations.SimulationParameters.debug) { System.out.println("refuse"); } if (negative) { return true; } else { return false; } } else { if (simulations.SimulationParameters.debug) { System.out.println("accepte"); } if (negative) { return false; } else { return true; } } } /** * 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 returns true if the player p is already in notAskingList * @return true if the player p is already in notAskingList false otherwise **/ private boolean containsPlayer(Player p) { for(int i=0;i