use of aima.core.util.datastructure.XYLocation in project aima-java by aimacode.
the class TicTacToeTest method testVerticalLineThroughBoard.
@Test
public void testVerticalLineThroughBoard() {
state.mark(0, 0);
state.mark(1, 0);
state.mark(0, 1);
state.mark(1, 1);
Assert.assertEquals(false, state.lineThroughBoard());
state.mark(new XYLocation(0, 2));
Assert.assertEquals(true, state.lineThroughBoard());
}
use of aima.core.util.datastructure.XYLocation in project aima-java by aimacode.
the class NQueensBoardTest method testSimpleDiagonalAttack.
@Test
public void testSimpleDiagonalAttack() {
XYLocation loc = new XYLocation(3, 3);
board.addQueenAt(loc);
Assert.assertEquals(0, board.getNumberOfAttacksOn(loc));
Assert.assertEquals(1, board.getNumberOfAttacksOn(loc.down().right()));
Assert.assertEquals(1, board.getNumberOfAttacksOn(loc.down().left()));
Assert.assertEquals(1, board.getNumberOfAttacksOn(loc.up().left()));
Assert.assertEquals(1, board.getNumberOfAttacksOn(loc.up().right()));
Assert.assertEquals(1, board.getNumberOfAttacksOn(new XYLocation(7, 7)));
Assert.assertEquals(1, board.getNumberOfAttacksOn(new XYLocation(0, 0)));
Assert.assertEquals(1, board.getNumberOfAttacksOn(new XYLocation(6, 0)));
Assert.assertEquals(1, board.getNumberOfAttacksOn(new XYLocation(0, 6)));
}
use of aima.core.util.datastructure.XYLocation in project aima-java by aimacode.
the class NQueensBoardTest method testMoveQueen.
@Test
public void testMoveQueen() {
XYLocation from = new XYLocation(0, 0);
XYLocation to = new XYLocation(1, 1);
board.addQueenAt(from);
Assert.assertEquals(1, board.getNumberOfQueensOnBoard());
Assert.assertTrue(board.queenExistsAt(from));
Assert.assertFalse(board.queenExistsAt(to));
board.moveQueen(from, to);
Assert.assertEquals(1, board.getNumberOfQueensOnBoard());
Assert.assertFalse(board.queenExistsAt(from));
Assert.assertTrue(board.queenExistsAt(to));
}
use of aima.core.util.datastructure.XYLocation in project aima-java by aimacode.
the class NQueensBoardTest method testBoardDisplay.
@Test
public void testBoardDisplay() {
board.addQueenAt(new XYLocation(0, 5));
board.addQueenAt(new XYLocation(1, 6));
board.addQueenAt(new XYLocation(2, 1));
board.addQueenAt(new XYLocation(3, 3));
board.addQueenAt(new XYLocation(4, 6));
board.addQueenAt(new XYLocation(5, 4));
board.addQueenAt(new XYLocation(6, 7));
board.addQueenAt(new XYLocation(7, 7));
Assert.assertEquals(" - - - - - - - - \n" + " - - Q - - - - - \n" + " - - - - - - - - \n" + " - - - Q - - - - \n" + " - - - - - Q - - \n" + " Q - - - - - - - \n" + " - Q - - Q - - - \n" + " - - - - - - Q Q \n", board.getBoardPic());
Assert.assertEquals("--------\n" + "--Q-----\n" + "--------\n" + "---Q----\n" + "-----Q--\n" + "Q-------\n" + "-Q--Q---\n" + "------QQ\n", board.toString());
}
use of aima.core.util.datastructure.XYLocation in project aima-java by aimacode.
the class NQueensBoardTest method testAttack3.
@Test
public void testAttack3() {
board.addQueenAt(new XYLocation(0, 0));
Assert.assertEquals(true, board.isSquareUnderAttack(new XYLocation(0, 1)));
}
Aggregations