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...