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)));
}
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)));
}
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)));
}
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());
}
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());
}
Aggregations