/*
* CoalitionalDef5AttackStrategy.java
*
* Created on May 25, 2004, 11:46 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 5) from last turn
* @author tom
*/
public class CoalitionalDef5AttackStrategy extends AttackStrategy {
/** The coalition **/
private ArrayList coalition;
/** Creates a new instance of CoalitionalDef5AttackStrategy */
public CoalitionalDef5AttackStrategy() {
super();
name="CoalitionalDef5AttackStrategy";
negative=false;
coalition=new ArrayList();
memoryParam=false;
abr="14";
}
/** 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 5)\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("CoalDef5AttackStrat : 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