Examples of TicTacToe


Examples of aima.core.environment.tictactoe.TicTacToe

   
    /** Handles all button events and updates the view. */
    @Override
    public void actionPerformed(ActionEvent ae) {
      if (ae == null || ae.getSource() == clear) {
        game = new TicTacToe();
      } else if (!game.hasEnded()) {
        if (ae.getSource() == proposal) {
          if (strategy.getSelectedIndex() == 0)
            game.makeMiniMaxMove();
          else
View Full Code Here

Examples of aima.core.environment.tictactoe.TicTacToe

  }

  private static void alphaBetaDemo() {
    System.out.println("ALPHA BETA ");
    System.out.println("");
    TicTacToe t4 = new TicTacToe();
    while (!(t4.hasEnded())) {
      System.out.println("\n" + t4.getPlayerToMove(t4.getState())
          + "  playing ... ");

      t4.makeAlphaBetaMove();
      GameState presentState = t4.getState();
      TicTacToeBoard board = t4.getBoard(presentState);
      board.print();
    }
    System.out.println("ALPHA BETA DEMO done");
  }
View Full Code Here

Examples of aima.core.environment.tictactoe.TicTacToe

  }

  private static void minimaxDemo() {
    System.out.println("MINI MAX ");
    System.out.println("");
    TicTacToe t3 = new TicTacToe();
    while (!(t3.hasEnded())) {
      System.out.println("\n" + t3.getPlayerToMove(t3.getState())
          + " playing");
      System.out.println("");
      t3.makeMiniMaxMove();
      GameState presentState = t3.getState();
      TicTacToeBoard board = t3.getBoard(presentState);
      System.out.println("");
      board.print();

    }
    System.out.println("Mini MAX DEMO done");
View Full Code Here

Examples of aima.core.environment.tictactoe.TicTacToe

  }

  @Test
  public void testAlphaBetaMinValueCalculation() {
    // board x o x , o o x,- x -
    TicTacToe t = new TicTacToe();

    t.makeMove(0, 0); // x
    t.makeMove(0, 1); // o
    t.makeMove(0, 2); // x

    t.makeMove(1, 0); // o
    t.makeMove(1, 2); // x
    t.makeMove(1, 1); // o

    t.makeMove(2, 1); // x

    int minValue = t.minValue(t.getState(), new AlphaBeta(
        Integer.MIN_VALUE, Integer.MAX_VALUE));
    Assert.assertEquals(0, minValue);
  }
View Full Code Here

Examples of aima.core.environment.tictactoe.TicTacToe

  private void checkSuccessorList(List<GameState> successorList,
      String playerToMove, int sizeOfSuccessors) {
    for (int i = 0; i < successorList.size(); i++) {
      GameState h = successorList.get(i);

      List<GameState> successors2 = new TicTacToe().getSuccessorStates(h);
      Assert.assertEquals(sizeOfSuccessors, successors2.size());
      Assert.assertEquals(playerToMove,
          new TicTacToe().getPlayerToMove(h));
    }
  }
View Full Code Here

Examples of aima.core.environment.tictactoe.TicTacToe

   * t4.minValue(t4.getState()); System.out.println("j = " + j);
   * assertEquals(-1,i); assertEquals(-1,j); }
   */
  @Test
  public void testGenerateSuccessors() {
    TicTacToe t3 = new TicTacToe();
    List<GameState> successors = t3.getSuccessorStates(t3.getState());
    Assert.assertEquals(9, successors.size());
    checkSuccessorList(successors, "O", 8);
    List<GameState> successors2 = t3.getSuccessorStates((GameState) successors
        .get(0));
    checkSuccessorList(successors2, "X", 7);
    List<GameState> successors3 = t3.getSuccessorStates((GameState) successors2
        .get(0));
    checkSuccessorList(successors3, "O", 6);
  }
View Full Code Here

Examples of aima.core.environment.tictactoe.TicTacToe

    Assert.assertTrue(!(gs1.equals(gs2)));
  }

  @Test
  public void testMiniMax() {
    TicTacToe t3 = new TicTacToe();
    t3.makeMove(0, 0);
    t3.makeMove(2, 2);
    t3.makeMove(2, 0);
    t3.makeMove(1, 1);
    Assert.assertEquals(1, t3.getMiniMaxValue(t3.getState()));
  }
View Full Code Here

Examples of aima.core.environment.tictactoe.TicTacToe

    Assert.assertEquals(1, t3.getMiniMaxValue(t3.getState()));
  }

  @Test
  public void testMiniMax2() {
    TicTacToe t3 = new TicTacToe();
    t3.makeMove(0, 0);
    t3.makeMove(2, 2);
    t3.makeMove(2, 0);

    Assert.assertEquals(1, t3.getMiniMaxValue(t3.getState()));
  }
View Full Code Here

Examples of aima.core.environment.tictactoe.TicTacToe

    Assert.assertEquals(1, t3.getMiniMaxValue(t3.getState()));
  }

  @Test
  public void testMiniMax3() {
    TicTacToe t3 = new TicTacToe();
    t3.makeMove(0, 0);
    t3.makeMove(1, 1);

    Assert.assertEquals(0, t3.getMiniMaxValue(t3.getState()));
  }
View Full Code Here

Examples of aima.core.environment.tictactoe.TicTacToe

    Assert.assertEquals(0, t3.getMiniMaxValue(t3.getState()));
  }

  @Test
  public void testMiniMax7() {
    TicTacToe t3 = new TicTacToe();
    t3.makeMove(0, 0);
    t3.makeMove(0, 1);

    Assert.assertEquals(1, t3.getMiniMaxValue(t3.getState()));
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.