Пример #1
0
  /**
   * Makes this player's moves until the referee says the game is over or one of the players has
   * won.
   */
  public static void makeMoves() {
    Move move;
    while (true) {
      if (currentGameState.getTurn() == Player.MAX) {
        move =
            MinMax.getInstance()
                .getNextBestMove(currentGameState, timelimit, Heuristic.getInstance());
        Communicator.getInstance().sendCmd(Main.getMoveAsCommand(move));
        logger.log(Level.INFO, "Player " + playerNumber + " move: " + move.toString());
      } else {
        String command = Communicator.getInstance().getCmd();
        if (Main.gameIsOver(command)) {
          break;
        }

        String args[] = command.split(" ");
        int col = Integer.parseInt(args[0]);
        int moveType = Integer.parseInt(args[1]);

        move = new Move((moveType == 0) ? MoveType.POP : MoveType.DROP, col);
      }

      currentGameState.move(move);
    }
  }
Пример #2
0
 /** Main function. */
 public static void main(String[] args) {
   Main.setUpHeuristics(args);
   Main.init();
   Main.setUpLogger();
   Main.makeMoves();
 }