public static <TSquare extends ReadOnlySquare> ImmutableList<SquaresSequence<TSquare>> generate(
      Game<TSquare> game) {
    ThrowHelper.throwOnNull(game, "game");

    ArrayList<SquaresSequence<TSquare>> promisingSequences =
        Lists.newArrayListWithCapacity(GameBoardPosition.DIMENSION + 2);

    for (int i = 0; i < GameBoardPosition.DIMENSION; ++i) {
      addIfPromising(promisingSequences, new RowSequence<TSquare>(game, i));
      addIfPromising(promisingSequences, new ColumnSequence<TSquare>(game, i));
    }

    addIfPromising(promisingSequences, new MainDiagonalSequence<TSquare>(game));
    addIfPromising(promisingSequences, new SecondaryDiagonalSequence<TSquare>(game));

    return ImmutableList.copyOf(promisingSequences);
  }
예제 #2
0
 public static GameFacade loadGame(String fileName) throws GamesXmlRepositoryException {
   return loadGame(new File(ThrowHelper.throwOnNull(fileName, "fileName")));
 }
예제 #3
0
 public void save(String fileName) throws GamesXmlRepositoryException {
   save(new File(ThrowHelper.throwOnNull(fileName, "fileName")));
 }
예제 #4
0
  public PlayerAI createComputerAI(GameDifficulty difficulty) {
    ThrowHelper.throwOnNull(difficulty, "difficulty");

    return PlayerAIFactory.create(getGame(), difficulty.movesAhead());
  }