Package aima.core.environment.tictactoe

Examples of aima.core.environment.tictactoe.TicTacToe


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

  @Test
  public void tesMiniMax4() {
    TicTacToe t3 = new TicTacToe();

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


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

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

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

  }

  @Test
  public void testMiniMax15() {

    TicTacToe t1 = new TicTacToe();
    t1.makeMove(0, 0);

    int minimax1 = t1.getMiniMaxValue(t1.getState());
    TicTacToe t2 = new TicTacToe();
    t2.makeMove(0, 2);
    int minimax2 = t2.getMiniMaxValue(t2.getState());
    TicTacToe t3 = new TicTacToe();
    t3.makeMove(2, 0);
    t3.getMiniMaxValue(t3.getState());
    TicTacToe t4 = new TicTacToe();
    t4.getMiniMaxValue(t4.getState());
    t4.makeMove(2, 2);

    Assert.assertEquals(minimax1, minimax2);
  }
View Full Code Here

    Assert.assertEquals(minimax1, minimax2);
  }

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

    t3.makeMove(2, 2);
    t3.makeMove(1, 2);

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

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

  @Test
  public void testAlphaBeta() {
    TicTacToe t1 = new TicTacToe();
    int alphabeta0 = t1.getAlphaBetaValue(t1.getState());
    Assert.assertEquals(0, alphabeta0);
    t1.makeMove(0, 0);

    int alphabeta1 = t1.getAlphaBetaValue(t1.getState());
    Assert.assertEquals(0, alphabeta1);
    TicTacToe t2 = new TicTacToe();
    t2.makeMove(0, 2);
    int alphabeta2 = t2.getAlphaBetaValue(t2.getState());
    Assert.assertEquals(0, alphabeta2);

    TicTacToe t3 = new TicTacToe();
    t3.makeMove(2, 0);
    int alphabeta3 = t3.getAlphaBetaValue(t3.getState());
    Assert.assertEquals(0, alphabeta3);

    TicTacToe t4 = new TicTacToe();
    int alphabeta4 = t4.getAlphaBetaValue(t4.getState());
    t4.makeMove(2, 2);

    Assert.assertEquals(0, alphabeta4);
  }
View Full Code Here

    tb = new TicTacToeBoard();
  }

  @Test
  public void testCreation() {
    TicTacToe t3 = new TicTacToe();
    Assert.assertEquals(9, t3.getMoves(t3.getState()).size());
    Assert.assertEquals("X", t3.getPlayerToMove(t3.getState()));
  }
View Full Code Here

    Assert.assertEquals(true, tb.isEmpty(2, 2));
  }

  @Test
  public void testMovingBumpsLevelByOne() {
    TicTacToe t1 = new TicTacToe();
    int level = t1.getLevel(t1.getState());
    Assert.assertEquals(0, level);
    t1.makeMove(0, 0);
    level = t1.getLevel(t1.getState());
    Assert.assertEquals(1, level);
  }
View Full Code Here

    Assert.assertEquals(true, tb.isAnyDiagonalComplete());
  }

  @Test
  public void testGivenABoardNUmberOfPossibleMovesCalculatedCorrectly() {
    TicTacToe t3 = new TicTacToe();
    Assert.assertEquals(9, t3.getMoves(t3.getState()).size());

    Assert.assertEquals("X", t3.getPlayerToMove(t3.getState()));
    t3.makeMove(t3.getState(), 0, 0);

    Assert.assertEquals(8, t3.getMoves(t3.getState()).size());
    Assert.assertEquals("O", t3.getPlayerToMove(t3.getState()));

    // try illegal move
    t3.makeMove(t3.getState(), 0, 0);
    Assert.assertEquals(8, t3.getMoves(t3.getState()).size());
    Assert.assertEquals("O", t3.getPlayerToMove(t3.getState()));

    t3.makeMove(t3.getState(), 1, 1);
    Assert.assertEquals(7, t3.getMoves(t3.getState()).size());
    Assert.assertEquals("X", t3.getPlayerToMove(t3.getState()));
  }
View Full Code Here

  }

  @Test
  public void testCalculateUtilityOfABoard() {
    // game 1
    TicTacToe t3 = new TicTacToe();
    t3.makeMove(t3.getState(), 0, 0);
    Assert.assertEquals(0, t3.getUtility(t3.getState()));
    t3.makeMove(t3.getState(), 2, 2);
    Assert.assertEquals(0, t3.getUtility(t3.getState()));
    t3.makeMove(t3.getState(), 2, 0);
    Assert.assertEquals(0, t3.getUtility(t3.getState()));
    t3.makeMove(t3.getState(), 1, 0);
    Assert.assertEquals(0, t3.getUtility(t3.getState()));
    t3.makeMove(t3.getState(), 0, 2);
    Assert.assertEquals(0, t3.getUtility(t3.getState()));
    t3.makeMove(t3.getState(), 0, 1);
    Assert.assertEquals(0, t3.getUtility(t3.getState()));
    t3.makeMove(t3.getState(), 1, 1);
    Assert.assertEquals(1, t3.computeUtility((t3.getState())));

    // game 2
    TicTacToe t4 = new TicTacToe();
    t4.makeMove(t4.getState(), 0, 0);
    Assert.assertEquals(0, t4.getUtility(t4.getState()));
    t4.makeMove(t4.getState(), 0, 1);
    Assert.assertEquals(0, t4.getUtility(t4.getState()));
    t4.makeMove(t4.getState(), 0, 2);
    Assert.assertEquals(0, t4.getUtility(t4.getState()));
    t4.makeMove(t4.getState(), 1, 0);
    Assert.assertEquals(0, t4.getUtility(t4.getState()));
    t4.makeMove(t4.getState(), 1, 1);
    Assert.assertEquals(0, t4.getUtility(t4.getState()));
    t4.makeMove(t4.getState(), 1, 2);
    Assert.assertEquals(0, t4.getUtility(t4.getState()));
    t4.makeMove(t4.getState(), 2, 0);

    Assert.assertEquals(1, t4.computeUtility(t4.getState()));
  }
View Full Code Here

TOP

Related Classes of aima.core.environment.tictactoe.TicTacToe

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.