Search in sources :

Example 21 with XYLocation

use of aima.core.util.datastructure.XYLocation in project aima-java by aimacode.

the class NQueensBoardTest method testMoveNonExistentQueen.

@Test
public void testMoveNonExistentQueen() {
    XYLocation from = new XYLocation(0, 0);
    XYLocation to = new XYLocation(1, 1);
    board.moveQueen(from, to);
    Assert.assertEquals(0, board.getNumberOfQueensOnBoard());
}
Also used : XYLocation(aima.core.util.datastructure.XYLocation) Test(org.junit.Test)

Example 22 with XYLocation

use of aima.core.util.datastructure.XYLocation in project aima-java by aimacode.

the class NQueensBoardTest method testRemoveNonExistentQueen.

@Test
public void testRemoveNonExistentQueen() {
    board.removeQueenFrom(new XYLocation(0, 0));
    Assert.assertEquals(0, board.getNumberOfQueensOnBoard());
}
Also used : XYLocation(aima.core.util.datastructure.XYLocation) Test(org.junit.Test)

Example 23 with XYLocation

use of aima.core.util.datastructure.XYLocation in project aima-java by aimacode.

the class NQueensBoardTest method testBasics.

@Test
public void testBasics() {
    Assert.assertEquals(0, board.getNumberOfQueensOnBoard());
    board.addQueenAt(new XYLocation(0, 0));
    Assert.assertEquals(1, board.getNumberOfQueensOnBoard());
    board.addQueenAt(new XYLocation(0, 0));
    Assert.assertEquals(1, board.getNumberOfQueensOnBoard());
    board.addQueenAt(new XYLocation(1, 1));
    Assert.assertEquals(2, board.getNumberOfQueensOnBoard());
    Assert.assertTrue(board.queenExistsAt(new XYLocation(1, 1)));
    Assert.assertTrue(board.queenExistsAt(new XYLocation(0, 0)));
    board.moveQueen(new XYLocation(1, 1), new XYLocation(3, 3));
    Assert.assertTrue(board.queenExistsAt(new XYLocation(3, 3)));
    Assert.assertTrue(!(board.queenExistsAt(new XYLocation(1, 1))));
    Assert.assertEquals(2, board.getNumberOfQueensOnBoard());
}
Also used : XYLocation(aima.core.util.datastructure.XYLocation) Test(org.junit.Test)

Example 24 with XYLocation

use of aima.core.util.datastructure.XYLocation in project aima-java by aimacode.

the class NQueensBoardTest method testCornerQueenAttack2.

@Test
public void testCornerQueenAttack2() {
    board.addQueenAt(new XYLocation(7, 7));
    Assert.assertEquals(true, board.isSquareUnderAttack(new XYLocation(0, 0)));
    Assert.assertEquals(true, board.isSquareUnderAttack(new XYLocation(7, 0)));
    Assert.assertEquals(true, board.isSquareUnderAttack(new XYLocation(0, 7)));
    Assert.assertEquals(true, board.isSquareUnderAttack(new XYLocation(7, 0)));
    Assert.assertEquals(true, board.isSquareUnderAttack(new XYLocation(6, 6)));
    Assert.assertEquals(true, board.isSquareUnderAttack(new XYLocation(5, 5)));
    Assert.assertEquals(false, board.isSquareUnderAttack(new XYLocation(6, 5)));
    Assert.assertEquals(false, board.isSquareUnderAttack(new XYLocation(5, 6)));
}
Also used : XYLocation(aima.core.util.datastructure.XYLocation) Test(org.junit.Test)

Example 25 with XYLocation

use of aima.core.util.datastructure.XYLocation in project aima-java by aimacode.

the class NQueensCspApp method getBoard.

private NQueensBoard getBoard(Assignment<Variable, Integer> assignment) {
    NQueensBoard board = new NQueensBoard(csp.getVariables().size());
    for (Variable var : assignment.getVariables()) {
        int col = Integer.parseInt(var.getName().substring(1)) - 1;
        int row = assignment.getValue(var) - 1;
        board.addQueenAt(new XYLocation(col, row));
    }
    return board;
}
Also used : XYLocation(aima.core.util.datastructure.XYLocation) NQueensBoard(aima.core.environment.nqueens.NQueensBoard)

Aggregations

XYLocation (aima.core.util.datastructure.XYLocation)56 Test (org.junit.Test)42 TicTacToeState (aima.core.environment.tictactoe.TicTacToeState)5 NQueensBoard (aima.core.environment.nqueens.NQueensBoard)4 Wall (aima.core.environment.xyenv.Wall)4 MockAgent (aima.test.core.unit.agent.impl.MockAgent)4 ArrayList (java.util.ArrayList)4 AbstractAgent (aima.core.agent.impl.AbstractAgent)3 GoalTest (aima.core.search.framework.problem.GoalTest)3 EnvironmentObject (aima.core.agent.EnvironmentObject)2 TicTacToeGame (aima.core.environment.tictactoe.TicTacToeGame)2 XYEnvironment (aima.core.environment.xyenv.XYEnvironment)1 IterativeDeepeningAlphaBetaSearch (aima.core.search.adversarial.IterativeDeepeningAlphaBetaSearch)1 LinkedHashSet (java.util.LinkedHashSet)1 Background (javafx.scene.layout.Background)1 BackgroundFill (javafx.scene.layout.BackgroundFill)1 ColumnConstraints (javafx.scene.layout.ColumnConstraints)1 RowConstraints (javafx.scene.layout.RowConstraints)1 StackPane (javafx.scene.layout.StackPane)1 Polygon (javafx.scene.shape.Polygon)1