KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > innig > macker > example > modularity > player > impl > TitForTatPlayer


1 package net.innig.macker.example.modularity.player.impl;
2
3 import net.innig.macker.example.modularity.player.*;
4 import net.innig.macker.example.modularity.game.*;
5 import java.util.*;
6
7 public class TitForTatPlayer
8     implements Player
9     {
10     public Move nextMove(Set legalMoves, Move otherPreviousMove)
11         {
12         return (otherPreviousMove != null)
13             ? otherPreviousMove
14             : fallback.nextMove(legalMoves, otherPreviousMove);
15         }
16     
17     private RandomPlayer fallback = new RandomPlayer();
18     }
Popular Tags