ipdlx
Class Strategy

java.lang.Object
  extended by ipdlx.Strategy
All Implemented Interfaces:
PDValues, java.lang.Cloneable
Direct Known Subclasses:
ALLC, ALLD, GRIM, Historical, MRAND, NEG, Pavlov, RAND, STFT, TFT, TFTT

public abstract class Strategy
extends java.lang.Object
implements PDValues, java.lang.Cloneable

Base abstract class for all strategies.

Author:
Tomasz Kaczanowski, Jan Humble

Field Summary
protected  double lastResult
          info about last game's result.
protected  int nrOfOpponents
           
protected  double opponentMove
          info about last opponent's move - did he defect or cooperate.
protected  double[] opponentsMoves
          info about last opponent's move - did he defect or cooperate.
 
Fields inherited from interface ipdlx.PDValues
COOPERATE, DEFAULT_MISTAKE_LEVEL, DEFAULT_PUNISHMENT, DEFAULT_REWARD, DEFAULT_SUCKER, DEFAULT_TEMPTATION, DEFECT, EXIT, moves, PLAYER_A, PLAYER_B
 
Constructor Summary
Strategy(java.lang.String abbrName, java.lang.String name, java.lang.String description)
          Constructor for "dirty" strategies.
 
Method Summary
protected  java.lang.Object clone()
          returns full name of the strategy
 java.lang.String getAbbrName()
          returns strategy abbreviated name
 java.lang.String getDescription()
          returns strategy description
 double getFinalMove(double move)
          Deprecated. This used to implement noise, but is now implemeneted in the Game class.
 java.lang.String getFullName()
           
abstract  double getMove()
          returns move
 java.lang.String getName()
          returns strategy name
 int getNumberOfOpponents()
           
 double getOpponentMove()
           
 double[] getOpponentsMoves()
           
protected  double getResult()
          returns strategy result
 void reset()
          sets the initial state of this strategy
 void setLastResult(double lastResult)
           
 void setNumberOfOpponents(int nrOfOpponents)
           
 void setOpponentMove(double opponentMove)
          setter for opponentMove field.
 void setOpponentsMoves(double[] opponentsMoves)
          setter for opponentsMoves field.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

opponentMove

protected double opponentMove
info about last opponent's move - did he defect or cooperate. *not every strategy uses this variable


opponentsMoves

protected double[] opponentsMoves
info about last opponent's move - did he defect or cooperate. *not every strategy uses this variable


lastResult

protected double lastResult
info about last game's result. not every strategy uses this variable


nrOfOpponents

protected int nrOfOpponents
Constructor Detail

Strategy

public Strategy(java.lang.String abbrName,
                java.lang.String name,
                java.lang.String description)
Constructor for "dirty" strategies. Sets: result to 0 also sets strategy names and description

Parameters:
abbrName - abbreviated name of strategy, eg. "TFT"
name - name of strategy, eg. "Tit-For-Tat"
description - description of strategy, how does it works, when does it coopearate and defect
Method Detail

getMove

public abstract double getMove()
returns move

Returns:
move of this strategy

setLastResult

public void setLastResult(double lastResult)

getNumberOfOpponents

public final int getNumberOfOpponents()

setNumberOfOpponents

public final void setNumberOfOpponents(int nrOfOpponents)

getResult

protected final double getResult()
returns strategy result

Returns:
strategy's result (the number of points gathered during game(s)

getDescription

public java.lang.String getDescription()
returns strategy description

Returns:
strategy's description

getName

public java.lang.String getName()
returns strategy name

Returns:
strategy's name

getAbbrName

public java.lang.String getAbbrName()
returns strategy abbreviated name

Returns:
strategy's abbreviated name

clone

protected java.lang.Object clone()
                          throws java.lang.CloneNotSupportedException
returns full name of the strategy

Overrides:
clone in class java.lang.Object
Returns:
full name of the strategy "abbrName (FullName)"
Throws:
java.lang.CloneNotSupportedException

getFullName

public java.lang.String getFullName()

setOpponentMove

public final void setOpponentMove(double opponentMove)
setter for opponentMove field. if your strategy doesn't use last opponent move in its next move calculations, setting of this field won't hurt it

Parameters:
opponentMove - last move of the opponent

setOpponentsMoves

public final void setOpponentsMoves(double[] opponentsMoves)
setter for opponentsMoves field. if your strategy doesn't use last opponent move in its next move calculations, setting of this field won't hurt it

Parameters:
opponentsMoves - last move of all the opponents

getOpponentsMoves

public final double[] getOpponentsMoves()

getOpponentMove

public final double getOpponentMove()

getFinalMove

public final double getFinalMove(double move)
Deprecated. This used to implement noise, but is now implemeneted in the Game class.


reset

public void reset()
sets the initial state of this strategy


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object