simulations.core.strategy.completeStrategy
Class GenericComposedStrategy

java.lang.Object
  extended by simulations.core.strategy.Strategy
      extended by simulations.core.strategy.completeStrategy.CompleteStrategy
          extended by simulations.core.strategy.completeStrategy.GenericComposedStrategy
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable
Direct Known Subclasses:
AdvancedCoalitionalDef1Strategy, AdvancedCoalitionalDef2Strategy, AdvancedCoalitionalDef3Strategy, AdvancedCoalitionalDef4Strategy, AdvancedCoalitionalDef5Strategy, AltruistStrategy, BadStrategy, PersistentStrategy2Memory0, PersistentStrategy2Memory10, PersistentStrategy2Memory5, PersistentStrategyMemory0, PersistentStrategyMemory10, PersistentStrategyMemory5, PowerStrategy, SimpleCoalitionalDef1Strategy, SimpleCoalitionalDef2Strategy, SimpleCoalitionalDef3Strategy, SimpleCoalitionalDef4Strategy, SimpleCoalitionalDef5Strategy, SpitefulStrategy2Memory0, SpitefulStrategy2Memory10, SpitefulStrategy2Memory5, SpitefulStrategy3Memory0, SpitefulStrategy3Memory10, SpitefulStrategy3Memory5, SpitefulStrategyMemory0, SpitefulStrategyMemory10, SpitefulStrategyMemory5, StupidStrategy

public class GenericComposedStrategy
extends CompleteStrategy
implements java.io.Serializable

This class describes a generic CompsoedStrategy. We can add attack, asking and decision strategies. This class is generic because to create new Strategies we just have to extends this class and init the attack, asking and decision strategies.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class simulations.core.strategy.completeStrategy.CompleteStrategy
askingStrategyVector, attackStrategyVector, decisionStrategyVector
 
Fields inherited from class simulations.core.strategy.Strategy
abr, memory, name, randomGenerator
 
Constructor Summary
GenericComposedStrategy()
          Creates a new instance of GenericComposedStrategy
GenericComposedStrategy(java.lang.String name)
          Creates a new instance of GenericComposedStrategy
 
Method Summary
 java.lang.String getDescription()
          return the description of this strategy
 java.util.ArrayList getPlayersToAskSupport(Player player, Player attackedPlayer, java.util.ArrayList playerList)
          Returns the list of players to ask support.
 Player getPlayerToAttack(Player player, java.util.ArrayList playerList)
          return the player to attack
 boolean supportAttack(Player player, Player attackingPlayer, Player attackedPlayer, java.util.ArrayList playerList)
          return true if the player will support the attack.
 void updateAttacksInfos(Player player, java.util.ArrayList attacksList)
          This method is called by the judge after the decision of players to attack and to ask supports to inform the strategy
 void updateLastTurn(Turn turn, Player player, java.util.ArrayList remainingPlayers)
          This method is called by the judge to inform players of the last turn
 
Methods inherited from class simulations.core.strategy.completeStrategy.CompleteStrategy
equals, getAskingComposition, getAskingStrategyVector, getAttackComposition, getAttackStrategyVector, getDecisionComposition, getDecisionStrategyVector, setAskingStrategyVector, setAttackStrategyVector, setDecisionStrategyVector
 
Methods inherited from class simulations.core.strategy.Strategy
getAbr, getMemory, getName, getRandomGenerator, setAbr, setMemory, setName, setRandomGenerator, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GenericComposedStrategy

public GenericComposedStrategy()
Creates a new instance of GenericComposedStrategy


GenericComposedStrategy

public GenericComposedStrategy(java.lang.String name)
Creates a new instance of GenericComposedStrategy

Parameters:
name - The name of the strategy
Method Detail

getDescription

public java.lang.String getDescription()
return the description of this strategy

Specified by:
getDescription in class CompleteStrategy
Returns:
return the description of this strategy

getPlayerToAttack

public Player getPlayerToAttack(Player player,
                                java.util.ArrayList playerList)
                         throws ManyPlayerToAttackException,
                                NoPlayerToAttackException
return the player to attack

Specified by:
getPlayerToAttack in class CompleteStrategy
Parameters:
player - The attacking player
playerList - The list of avalaible player
Returns:
The player to attack
Throws:
ManyPlayerToAttackException - if this method would return more that one player to attack
NoPlayerToAttackException - if this method would return no player to attack

getPlayersToAskSupport

public java.util.ArrayList getPlayersToAskSupport(Player player,
                                                  Player attackedPlayer,
                                                  java.util.ArrayList playerList)
Returns the list of players to ask support.

Specified by:
getPlayersToAskSupport in class CompleteStrategy
Parameters:
attackedPlayer - The attacked player
player - The attacking player
playerList - The list of avalaible player
Returns:
Returns the list of players to ask support.

supportAttack

public boolean supportAttack(Player player,
                             Player attackingPlayer,
                             Player attackedPlayer,
                             java.util.ArrayList playerList)
return true if the player will support the attack.

Specified by:
supportAttack in class CompleteStrategy
Parameters:
playerList - The list of remaining players
player - The owner of the strategy
attackingPlayer - The attacking player
attackedPlayer - The attacked player
Returns:
return true if the player will support the attack.

updateAttacksInfos

public void updateAttacksInfos(Player player,
                               java.util.ArrayList attacksList)
This method is called by the judge after the decision of players to attack and to ask supports to inform the strategy

Specified by:
updateAttacksInfos in class CompleteStrategy
Parameters:
player - The player owner of this strategy
attacksList - The list of attacks

updateLastTurn

public void updateLastTurn(Turn turn,
                           Player player,
                           java.util.ArrayList remainingPlayers)
This method is called by the judge to inform players of the last turn

Specified by:
updateLastTurn in class CompleteStrategy
Parameters:
turn - The turn
player - The owner of the strategy
remainingPlayers - The list of the remaining players