/* * AskingPlayersNeverRefuseToHelpMe.java * * Created on April 26, 2004, 3:52 AM */ package simulations.core.strategy.askingSupportStrategy; 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 an asking support strategy that ask support * to all players that have never refuse to help me * @author tom */ public class AskingPlayersNeverRefuseToHelpMeStrategy extends AskingStrategy { /** This list store the players I ask support **/ private ArrayList notAskingList; /** True if it's the first call **/ private boolean first; /** Creates a new instance of AskingPlayersNeverRefuseToHelpMe */ public AskingPlayersNeverRefuseToHelpMeStrategy() { super(); first=true; notAskingList = new ArrayList(); name="AskingPlayersNeverRefuseToHelpMeStrategy"; memoryParam=true; abr="5"; } /** 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;iavalaible player */ public ArrayList getPlayersToAskSupport(Player player, Player attackedPlayer, ArrayList playerList) { if (simulations.SimulationParameters.debug) { System.out.println("notAskingList = "+notAskingList); } ArrayList l = new ArrayList(); if (negative) { Iterator it = playerList.iterator(); while (it.hasNext()) { Player p = (Player)it.next(); if (containsPlayer(p)) { l.add(p); } } } else { Iterator it = playerList.iterator(); while (it.hasNext()) { Player p = (Player)it.next(); if (!(containsPlayer(p))) { l.add(p); } } } if (simulations.SimulationParameters.debug) { System.out.println("l = "+l); } return l; } /** 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, Player player, ArrayList remainingPlayers) { // remove dead players for(int i=0;i