Advertisement
Guest User

Untitled

a guest
Apr 7th, 2020
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.88 KB | None | 0 0
  1. // To be implemented by all players
  2. interface Player {
  3.     void reset();
  4.     int move(int opponentLastMove, int xA, int xB, int xC);
  5. }
  6.  
  7. // Player implementations
  8. class AlwaysA implements Player {
  9.     AlwaysA() {}
  10.     @Override
  11.     public void reset() {}
  12.  
  13.     @Override
  14.     public int move(int opponentLastMove, int xA, int xB, int xC) {
  15.         return 1;
  16.     }
  17. }
  18.  
  19. /*
  20.     LIST OF OTHER PLAYER IMPLEMENTATIONS GOES HERE
  21. */
  22.  
  23. class Tournament {
  24.     Tournament(Player[] candidates, int numTurns, int numRepetitions) { ... }
  25.     void play() { ... }
  26.     void printResults() { ... }
  27. }
  28.  
  29. public class DragosStrugarTesting {
  30.     public static void main(String[] args) throws Exception {
  31.         Player[] candidates = new Player[2];
  32.         candidates[0] = new AlwaysA();
  33.         candidates[1] = new AlwaysB();
  34.        
  35.         Tournament t = new Tournament(candidates, 1000, 100);
  36.         t.play();
  37.         t.printResults();
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement