Package com.jacobpatterson.csci446.program1.core.agents

Examples of com.jacobpatterson.csci446.program1.core.agents.KonaneUI


         
          Stack<Move> selectedFileMoves = new Stack<Move>();
          while(scanner.hasNextLine())
          {
            String nextLine = scanner.nextLine();
            Move move = Move.valueOf(nextLine);
            selectedFileMoves.push(move);
          }
          moves = selectedFileMoves;
          konaneEventRegistry.fireEvent(
              KonaneEvent.REPLAY_GAME_RECORDING);
View Full Code Here


      konaneGame.resetBoard();
      KonanePiece turn = KonanePiece.BLACK;
      while(!konaneGame.isOver())
      {
        startTime = System.nanoTime();
        Move move = agents[turn.ordinal()].computeMove();
        endTime   = System.nanoTime();
        timings.put(turn.ordinal(),
            timings.get(turn.ordinal()) + (endTime - startTime));
        turn = turn.oppositeTurn();
        konaneGame.makeMove(move);
View Full Code Here

  protected abstract Move getMoveToMake();
 
  public Move computeMove()
  {
    long startTime = System.currentTimeMillis();
    Move move = this.getMoveToMake();
    long endTime = System.currentTimeMillis();
    System.out.println(String.format("%s took %.3f seconds to move.",
        this.toString(),
        (endTime - startTime) / 1000.0));
    return move;
View Full Code Here

      if(entry.getValue().equals(bestHeuristic))
      {
        bestMoves.add(entry.getKey());
      }
    }
    Move move = bestMoves.get(random.nextInt(bestMoves.size()));
    return move;
  }
View Full Code Here

  }

  @Override
  public void actionPerformed(ActionEvent event)
  {
    Move move = moves.pop();
    if(konaneGame.makeMove(move.getSource(),
        move.getDestination()))
    {
      konaneEventRegistry.fireEvent(KonaneEvent.MOVE_MADE);
      if(konaneGame.isOver())
      {
        this.stopReplay();
      }
    }
    else
    {
      Exception ex = new Exception(String.format(
          "The move '%s' is not vaild at the moment.\n"
              + "Stoping replay.",
          move.toString()));
      KonaneUtils.reportException(ex);
      this.stopReplay();
    }
  }
View Full Code Here

        break;
      case MOVE_MADE :
        konaneCanvas.removeMouseListener(konaneUI);
        this.updateInfoLabelText();
        konaneCanvas.repaint();
        PlayerType agentPlayerType
            = konaneGame.getAgentPlayerType(konaneGame.getTurn());
        if(!konaneGame.isOver() && agentPlayerType != null)
        {
          switch(agentPlayerType)
          {
View Full Code Here

  public void actionPerformed(ActionEvent event)
  {
    String command = event.getActionCommand();
    if(command.equals(OK_BUTTON))
    {
      PlayerType selectedBlackPlayerType = PlayerType.getPlayerType(
          blackButtonGroup.getSelection().getActionCommand());
      PlayerType selectedWhitePlayerType = PlayerType.getPlayerType(
          whiteButtonGroup.getSelection().getActionCommand());
      if(konaneGame.getBlackPlayerType() != selectedBlackPlayerType
          || konaneGame.getWhitePlayerType() != selectedWhitePlayerType)
      {
        if(konaneGame.hasStarted())
View Full Code Here

            case HUMAN :
              konaneCanvas.removeMouseListener(konaneUI);
              konaneCanvas.addMouseListener(konaneUI);
              break;
            default :
                Agent agentToMove
                    = agents[konaneGame.getTurn().ordinal()];
                agentMoveRetriever
                    = new AgentMoveRetriever(agentToMove);
                agentMoveRetriever.execute();
                agentMoveTimer.start();
View Full Code Here

              break;
            default :
                Agent agentToMove
                    = agents[konaneGame.getTurn().ordinal()];
                agentMoveRetriever
                    = new AgentMoveRetriever(agentToMove);
                agentMoveRetriever.execute();
                agentMoveTimer.start();
              break;
          }
        }
View Full Code Here

            agents[KonanePiece.BLACK.ordinal()]
                = new MinimaxAgent(konaneGame, blackSearchDepth);
            break;
          case ALPHA_BETA :
            agents[KonanePiece.BLACK.ordinal()]
                = new AlphabetaAgent(konaneGame, blackSearchDepth);
            break;
          case RANDOM :
            agents[KonanePiece.BLACK.ordinal()]
                = new RandomAgent(konaneGame);
            break;
        }
        switch(konaneGame.getWhitePlayerType())
        {
          case MINIMAX :
            agents[KonanePiece.WHITE.ordinal()]
                = new MinimaxAgent(konaneGame, whiteSearchDepth);
            break;
          case ALPHA_BETA :
            agents[KonanePiece.WHITE.ordinal()]
                = new AlphabetaAgent(konaneGame, whiteSearchDepth);
            break;
          case RANDOM :
            agents[KonanePiece.WHITE.ordinal()]
                = new RandomAgent(konaneGame);
            break;
View Full Code Here

TOP

Related Classes of com.jacobpatterson.csci446.program1.core.agents.KonaneUI

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.