Search in sources :

Example 16 with XYLocation

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

the class NQueensBoardTest method testSimpleHorizontalAttack.

@Test
public void testSimpleHorizontalAttack() {
    XYLocation loc = new XYLocation(0, 0);
    board.addQueenAt(loc);
    Assert.assertEquals(0, board.getNumberOfAttacksOn(loc));
    Assert.assertEquals(1, board.getNumberOfAttacksOn(new XYLocation(1, 0)));
    Assert.assertEquals(1, board.getNumberOfAttacksOn(loc.right()));
    Assert.assertEquals(1, board.getNumberOfAttacksOn(new XYLocation(7, 0)));
}
Also used : XYLocation(aima.core.util.datastructure.XYLocation) Test(org.junit.Test)

Example 17 with XYLocation

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

the class NQueensBoardTest method testEdgeQueenAttack.

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

Example 18 with XYLocation

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

the class NQueensBoardTest method testCornerDiagonalAttack.

@Test
public void testCornerDiagonalAttack() {
    board.addQueenAt(new XYLocation(0, 0));
    // forwardDiagonal from the queen
    Assert.assertTrue(board.isSquareUnderAttack(new XYLocation(1, 1)));
    board.clear();
    board.addQueenAt(new XYLocation(7, 7));
    // backwardDiagonal from the queen
    Assert.assertTrue(board.isSquareUnderAttack(new XYLocation(6, 6)));
// assertTrue(board.isSquareUnderAttack(new XYLocation(2, 2)));
// assertTrue(board.isSquareUnderAttack(new XYLocation(2, 4)));
}
Also used : XYLocation(aima.core.util.datastructure.XYLocation) Test(org.junit.Test)

Example 19 with XYLocation

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

the class NQueensBoardTest method testCornerQueenAttack1.

@Test
public void testCornerQueenAttack1() {
    board.addQueenAt(new XYLocation(0, 0));
    Assert.assertEquals(false, board.isSquareUnderAttack(new XYLocation(0, 0)));
    // queen on square not included
    Assert.assertEquals(true, board.isSquareUnderAttack(new XYLocation(1, 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(1, 1)));
    Assert.assertEquals(true, board.isSquareUnderAttack(new XYLocation(2, 2)));
    Assert.assertEquals(false, board.isSquareUnderAttack(new XYLocation(2, 1)));
    Assert.assertEquals(false, board.isSquareUnderAttack(new XYLocation(1, 2)));
}
Also used : XYLocation(aima.core.util.datastructure.XYLocation) Test(org.junit.Test)

Example 20 with XYLocation

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

the class NQueensBoardTest method testMidBoardDiagonalAttack.

@Test
public void testMidBoardDiagonalAttack() {
    board.addQueenAt(new XYLocation(3, 3));
    // forwardDiagonal from the queen
    Assert.assertTrue(board.isSquareUnderAttack(new XYLocation(4, 2)));
    Assert.assertTrue(board.isSquareUnderAttack(new XYLocation(4, 4)));
    // backwardDiagonal from the queen
    Assert.assertTrue(board.isSquareUnderAttack(new XYLocation(2, 2)));
    Assert.assertTrue(board.isSquareUnderAttack(new XYLocation(2, 4)));
}
Also used : XYLocation(aima.core.util.datastructure.XYLocation) Test(org.junit.Test)

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