/** * NEG.java * * A simple Strategy, implementing negation. * */ import ipdlx.Strategy; public class NEG extends Strategy { // You can call your class whatever (legal) name you like. // We reserve the right to change it to avoid clashes etc. // Please include a call to super, supplying three pieces of information. // 1) The acronym for your strategy (in this case NEG) // 2) A longer name for your strategy (in this case Negation) // 3) A fuller description public NEG() { super("NEG", "Negation", "NEG plays according to simple rules: if opponent plays COOPERATION, in next move NEG will play DEFECTION; if opponent plays DEFECTION NEG will play COOPERATION. First move will be random."); reset(); } // This is the function that returns your move. Of course, // it can be as simple or as complex as you like and you might // want to maintain your own state variables public double getMove() { if (opponentMove == DEFECT) { return COOPERATE; } return DEFECT; } // The reset function is called on the start of every game. // Implement it to for example to clear your strategy memory. public void reset() { opponentMove = (int) (Math.random() + 0.5); } }