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