/* * CoalitionalDef2AttackStrategy.java * * Created on May 25, 2004, 11:19 PM */ package simulations.core.strategy.attackStrategy; import java.util.ArrayList; import java.util.Iterator; import simulations.core.Player; import simulations.core.history.PlayerTurn; /** * This class describes an attack strategy that attack players that are * not in my coalition (definition 2) from last turn * @author tom */ public class CoalitionalDef2AttackStrategy extends AttackStrategy { /** The coalition **/ private ArrayList coalition; /** Creates a new instance of CoalitionalDef2AttackStrategy */ public CoalitionalDef2AttackStrategy() { super(); name="CoalitionalDef2AttackStrategy"; negative=false; coalition=new ArrayList(); memoryParam=false; abr="11"; } /** return the description of this attack strategy * @return return the description of this attack strategy **/ public String getDescription() { return "Attack strategy : I attack players\n"+ "that are not in my coalition (definition 2)\n"; } /** return the player to attack * @param player The attacking player * @param playerList The list of avalaible player * @return The player to attack */ public java.util.ArrayList getPlayerToAttack(simulations.core.Player player, java.util.ArrayList playerList) { if (simulations.SimulationParameters.debug) { System.out.println("CoalDef2AttackStrat : coalList = "+coalition.toString()); } ArrayList l = new ArrayList(); Iterator it = coalition.iterator(); while (it.hasNext()) { ArrayList l2 = (ArrayList)it.next(); Iterator it2 = l2.iterator(); while (it2.hasNext()) { Player p = (Player)it2.next(); if (!(l.contains(p))) { if (!(p.equals(player))) { l.add(p); } } } } if (negative) { return l; } else { ArrayList l2 = new ArrayList(); for(int i=0;i