/*
* AttackWeakestStrategy.java
*
* Created on April 9, 2004, 2:33 AM
*/
package simulations.core.strategy.attackStrategy;
import simulations.core.Player;
import java.util.ArrayList;
import java.util.Iterator;
import simulations.core.history.Turn;
/** This class describes an attack strategy that always attack the weaker of the
* remaining players
* @author tom
*/
public class AttackWeakestStrategy extends AttackStrategy {
/** Creates a new instance of AttackWeakestStrategy */
public AttackWeakestStrategy() {
super();
name="AttackWeakestStrategy";
memoryParam=false;
abr="8";
}
/** 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(Player player, ArrayList playerList) {
Iterator it = playerList.iterator();
float min=Float.MAX_VALUE;
ArrayList l = new ArrayList();
while (it.hasNext()) {
Player p = (Player)it.next();
if (p.equals(player)) {
continue;
}
if (p.getHitPoints()