Search in sources :

Example 1 with TicTacToeGame

use of aima.core.environment.tictactoe.TicTacToeGame in project aima-java by aimacode.

the class TicTacToeDemo method startMinimaxDemo.

private static void startMinimaxDemo() {
    System.out.println("MINI MAX DEMO\n");
    TicTacToeGame game = new TicTacToeGame();
    TicTacToeState currState = game.getInitialState();
    AdversarialSearch<TicTacToeState, XYLocation> search = MinimaxSearch.createFor(game);
    while (!(game.isTerminal(currState))) {
        System.out.println(game.getPlayer(currState) + "  playing ... ");
        XYLocation action = search.makeDecision(currState);
        currState = game.getResult(currState, action);
        System.out.println(currState);
    }
    System.out.println("MINI MAX DEMO done");
}
Also used : XYLocation(aima.core.util.datastructure.XYLocation) TicTacToeGame(aima.core.environment.tictactoe.TicTacToeGame) TicTacToeState(aima.core.environment.tictactoe.TicTacToeState)

Example 2 with TicTacToeGame

use of aima.core.environment.tictactoe.TicTacToeGame in project aima-java by aimacode.

the class TicTacToeDemo method startAlphaBetaDemo.

private static void startAlphaBetaDemo() {
    System.out.println("ALPHA BETA DEMO\n");
    TicTacToeGame game = new TicTacToeGame();
    TicTacToeState currState = game.getInitialState();
    AdversarialSearch<TicTacToeState, XYLocation> search = AlphaBetaSearch.createFor(game);
    while (!(game.isTerminal(currState))) {
        System.out.println(game.getPlayer(currState) + "  playing ... ");
        XYLocation action = search.makeDecision(currState);
        currState = game.getResult(currState, action);
        System.out.println(currState);
    }
    System.out.println("ALPHA BETA DEMO done");
}
Also used : XYLocation(aima.core.util.datastructure.XYLocation) TicTacToeGame(aima.core.environment.tictactoe.TicTacToeGame) TicTacToeState(aima.core.environment.tictactoe.TicTacToeState)

Example 3 with TicTacToeGame

use of aima.core.environment.tictactoe.TicTacToeGame in project aima-java by aimacode.

the class TicTacToeTest method setUp.

@Before
public void setUp() {
    game = new TicTacToeGame();
    state = game.getInitialState();
}
Also used : TicTacToeGame(aima.core.environment.tictactoe.TicTacToeGame) Before(org.junit.Before)

Example 4 with TicTacToeGame

use of aima.core.environment.tictactoe.TicTacToeGame in project aima-java by aimacode.

the class TicTacToeTest method testCreation.

@Test
public void testCreation() {
    game = new TicTacToeGame();
    state = game.getInitialState();
    Assert.assertEquals(9, game.getActions(state).size());
    Assert.assertEquals(TicTacToeState.X, game.getPlayer(state));
}
Also used : TicTacToeGame(aima.core.environment.tictactoe.TicTacToeGame) Test(org.junit.Test)

Example 5 with TicTacToeGame

use of aima.core.environment.tictactoe.TicTacToeGame in project aima-java by aimacode.

the class TicTacToeApp method initialize.

@Override
public void initialize() {
    game = new TicTacToeGame();
    currState = game.getInitialState();
    searchMetrics = null;
    update();
}
Also used : TicTacToeGame(aima.core.environment.tictactoe.TicTacToeGame)

Aggregations

TicTacToeGame (aima.core.environment.tictactoe.TicTacToeGame)5 TicTacToeState (aima.core.environment.tictactoe.TicTacToeState)2 XYLocation (aima.core.util.datastructure.XYLocation)2 Before (org.junit.Before)1 Test (org.junit.Test)1