/* * AttackRandomlyStrategy.java * * Created on April 14, 2004, 3:39 AM */ package simulations.core.strategy.attackStrategy; import java.util.ArrayList; import simulations.core.Player; import simulations.core.history.Turn; /** * This class describes a strategy that attack randomly a player * @author tom */ public class AttackRandomlyStrategy extends AttackStrategy { /** Creates a new instance of AttackRandomlyStrategy */ public AttackRandomlyStrategy() { super(); name="AttackRandomlyStrategy"; memoryParam=false; abr="3"; } /** return the player to attack * @param player The attacking player * @param playerList The list of avalaible player * @return The player to attack */ public ArrayList getPlayerToAttack(simulations.core.Player player, java.util.ArrayList playerList) { playerList.remove(player); int size = playerList.size(); int index=randomGenerator.nextInt(size); ArrayList l = new ArrayList(); l.add(playerList.get(index)); 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, simulations.core.Player player, java.util.ArrayList remainingPlayers) { } /** return the description of this attack strategy * @return return the description of this attack strategy **/ public String getDescription() { return "Attack strategy : \n"+ "I attack randomly a player in the list\n"; } }