Advertisement
Guest User

Untitled

a guest
Dec 6th, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1.  
  2. import java.util.InputMismatchException
  3. import java.util.concurrent.ThreadLocalRandom;
  4.  
  5. class RandomPlayer(name: String) extends Player(name: String) {
  6. /**
  7. * prints the name of the player, and asks via System.out what move the player wants to make.
  8. * waits for an int p in the interval [0,8], where game(p) == 0, from System.in.
  9. * return p.
  10. */
  11. def move(game: Array[Int], depth: Int): Int = {
  12.  
  13. val min = 0
  14. val max = 8
  15. var p = ThreadLocalRandom.current().nextInt(min, max + 1);
  16. // Random number assigned to p;
  17.  
  18.  
  19. while(game(p) != 0){
  20. p = ThreadLocalRandom.current().nextInt(min, max + 1);
  21. }
  22. return p;
  23.  
  24.  
  25. }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement