
public  class Strategy extends Object {
  int strategyNumber;  // each strategy will be assigned an ID number
  String name;         // and a name
  int pop;             // The number of players with this strategy

  // Moves are either "cooperate" ("nice") or "defect" ("nasty")
  public static final int COOPERATE = 0;
  public static final int DEFECT = 1;

  // This default Strategy always returns 0; it's Nice.

  public Strategy () {}

  public Strategy (int strategyNumberIn, String nameIn) {
    strategyNumber = strategyNumberIn;
    name = nameIn;
    pop = 0;
  }

  public void reset() { pop = 0; }

  protected int firstMove () {return COOPERATE;}
  // Override firstMove if the Strategy doesn't always cooperate on the first move
  
  protected int secondMove (int myLastPlay, int otherLastPlay, int currentScore)
    {return firstMove();}
  // The default secondMove acts as if the Strategy ignores the state of the game.
  // Override secondMove if the Strategy uses the results of the last move
  
  protected int thirdMove  (int myLastPlay, int otherLastPlay,
                            int myPreviousPlay, int otherPreviousPlay, int currentScore)
    {return secondMove (myLastPlay, otherLastPlay, currentScore);}
  // The default thirdMove acts the same as the second move.  Override it if the
  // Strategy can depend on the last two moves
    
  protected boolean leave (int myLastPlay, int otherLastPlay, int currentScore)
    {return false;}
  // The default strategy never breaks off play.
  
  public String toString() {
    return "["+strategyNumber+",name="+name+",pop="+pop+"]";
  
  } // toString
}

