ParallelGamePlayer
The ParallelGamePlayer
class implements the Player
interface that defines the play
method:
@Override public void play() { Table table = new Table(NR_COLUMNS, manager); Secret secret = new RandomSecret(manager); Guess secretGuess = secret.createSecret(NR_COLUMNS); Game game = new Game(table, secretGuess); final IntervalGuesser[] guessers = createGuessers(table); startAsynchronousGuessers(guessers); final Guesser finalCheckGuesser = new UniqueGuesser(table); try { while (!game.isFinished()) { final Guess guess = guessQueue.take(); if (finalCheckGuesser.guessMatch(guess)) { game.addNewGuess(guess); } } } catch (InterruptedException ie) { } finally { stopAsynchronousGuessers(guessers); } }
This method creates a Table, a RandomSecret
that creates the guess used as a secret in a random way, a Game
object, IntervalGuesser...