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

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


    int unit = konaneCanvas.getUnit();
    pressedX /= unit;
    pressedY /= unit;
    int releasedX = event.getX() / unit;
    int releasedY = event.getY() / unit;
    if(konaneGame.makeMove(new Cell(pressedX, pressedY),
        new Cell(releasedX, releasedY)))
    {
      konaneEventRegistry.fireEvent(KonaneEvent.MOVE_MADE);
      if(konaneGame.isOver())
      {
        konaneEventRegistry.fireEvent(KonaneEvent.GAME_OVER);
View Full Code Here


      return currentBoardState.getHeuristic();
    }
    int value = Integer.MIN_VALUE;
    for(Move move : currentBoardState.getPossibleMovesForCurrentTurn())
    {
      KonaneBoardState moveBoardState
          = currentBoardState.getCopy().makeMove(move);
      value = Math.max(value, this.minValue(moveBoardState, depth - 1));
    }
    return value;
  }
View Full Code Here

      return currentBoardState.getHeuristic();
    }
    int value = Integer.MAX_VALUE;
    for(Move move : currentBoardState.getPossibleMovesForCurrentTurn())
    {
      KonaneBoardState moveBoardState
          = currentBoardState.getCopy().makeMove(move);
      value = Math.min(value, this.maxValue(moveBoardState, depth - 1));
    }
    return value;
  }
View Full Code Here

      return currentBoardState.getHeuristic();
    }
    int value = Integer.MIN_VALUE;
    for(Move move : currentBoardState.getPossibleMovesForCurrentTurn())
    {
      KonaneBoardState moveBoardState
          = currentBoardState.getCopy().makeMove(move);
      value = Math.max(value, this.minValue(moveBoardState,
          depth - 1, alpha, beta));
      if(value >= beta)
      {
View Full Code Here

      return currentBoardState.getHeuristic();
    }
    int value = Integer.MAX_VALUE;
    for(Move move : currentBoardState.getPossibleMovesForCurrentTurn())
    {
      KonaneBoardState moveBoardState
          = currentBoardState.getCopy().makeMove(move);
      value = Math.min(value, this.maxValue(moveBoardState,
          depth - 1, alpha, beta));
      if(value <= alpha)
      {
View Full Code Here

    super("Konane");
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    this.agents = new Agent[2];

    konaneGameRecorder = new KonaneGameRecorder();
    konaneGame = new KonaneGame(dimension, konaneGameRecorder);
    konaneCanvas = new KonaneCanvas(konaneGame);
    konaneUI = new KonaneUI(konaneGame, konaneCanvas);
    konaneCanvas.addMouseListener(konaneUI);
    KonaneMenu konaneMenu = new KonaneMenu(konaneGame, konaneGameRecorder);
    for(int i = 0; i < konaneMenu.getMenuCount(); i++)
View Full Code Here

  private final int WHITE = KonanePiece.WHITE.ordinal();
  private int playNumber;
  private File gameTesterOutput;
  public GameTester()
  {
    this.konaneGame = new KonaneGame(6, null);
    this.playNumber = 0;
    gameTesterOutput = new File("gameTesterOutput.txt");
  }
View Full Code Here

    PrintStream out = System.out;
    long startTime, endTime;
    for(int g = 0; g < numGames; g++)
    {
      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);
      }
      int winner = turn.oppositeTurn().ordinal();
      scores.put(winner, scores.get(winner) + 1);
    }
    this.playNumber++;
    writer.write(String.format("Play number %d:\n", playNumber));
    writer.write(String.format("\tBLACK (%s): Won %d games and took %f seconds.\n",
View Full Code Here

    try
    {
      moveMade = konaneGame.makeMove(agentMoveRetriever.get());
      if(!moveMade)
      {
        Move lastMove = konaneGameRecorder.getLastMove();
        Exception ex = new Exception(
            String.format(
            "The Agent '%s' tried to make an invalid move '%s'",
            agents[konaneGame.getTurn().ordinal()].toString(),
            lastMove.toString()));
        KonaneUtils.reportException(ex);
      }
      else
      {
        KonaneUtils.fireEventLater(KonaneEvent.MOVE_MADE);
View Full Code Here

   * @param source The source Cell of the Move.
   * @param destination The destination Cell of the Move.
   */
  public void addMove(Cell source, Cell destination)
  {
    moves.push(new Move(source, destination));
  }
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.