Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.InputMismatchException
- import java.util.concurrent.ThreadLocalRandom;
- class RandomPlayer(name: String) extends Player(name: String) {
- /**
- * prints the name of the player, and asks via System.out what move the player wants to make.
- * waits for an int p in the interval [0,8], where game(p) == 0, from System.in.
- * return p.
- */
- def move(game: Array[Int], depth: Int): Int = {
- val min = 0
- val max = 8
- var p = ThreadLocalRandom.current().nextInt(min, max + 1);
- // Random number assigned to p;
- while(game(p) != 0){
- p = ThreadLocalRandom.current().nextInt(min, max + 1);
- }
- return p;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement