use of aima.core.util.datastructure.XYLocation in project aima-java by aimacode.
the class EightPuzzleBoardTest method testGetLocation.
@Test
public void testGetLocation() {
Assert.assertEquals(new XYLocation(0, 2), board.getLocationOf(0));
Assert.assertEquals(new XYLocation(1, 1), board.getLocationOf(1));
Assert.assertEquals(new XYLocation(2, 2), board.getLocationOf(2));
Assert.assertEquals(new XYLocation(2, 1), board.getLocationOf(3));
Assert.assertEquals(new XYLocation(0, 1), board.getLocationOf(4));
Assert.assertEquals(new XYLocation(0, 0), board.getLocationOf(5));
Assert.assertEquals(new XYLocation(1, 0), board.getLocationOf(6));
Assert.assertEquals(new XYLocation(2, 0), board.getLocationOf(7));
Assert.assertEquals(new XYLocation(1, 2), board.getLocationOf(8));
}
use of aima.core.util.datastructure.XYLocation in project aima-java by aimacode.
the class EightPuzzleBoardTest method testGetPositions.
@Test
public void testGetPositions() {
List<XYLocation> expected = new ArrayList<XYLocation>();
expected.add(new XYLocation(0, 2));
expected.add(new XYLocation(1, 1));
expected.add(new XYLocation(2, 2));
expected.add(new XYLocation(2, 1));
expected.add(new XYLocation(0, 1));
expected.add(new XYLocation(0, 0));
expected.add(new XYLocation(1, 0));
expected.add(new XYLocation(2, 0));
expected.add(new XYLocation(1, 2));
List<XYLocation> actual = board.getPositions();
Assert.assertEquals(expected, actual);
}
use of aima.core.util.datastructure.XYLocation in project aima-java by aimacode.
the class EightPuzzleBoardTest method testSetBoard.
@Test
public void testSetBoard() {
List<XYLocation> passedIn = new ArrayList<XYLocation>();
passedIn.add(new XYLocation(1, 1));
passedIn.add(new XYLocation(0, 2));
passedIn.add(new XYLocation(2, 2));
passedIn.add(new XYLocation(2, 1));
passedIn.add(new XYLocation(0, 1));
passedIn.add(new XYLocation(0, 0));
passedIn.add(new XYLocation(1, 0));
passedIn.add(new XYLocation(2, 0));
passedIn.add(new XYLocation(1, 2));
board.setBoard(passedIn);
Assert.assertEquals(new XYLocation(1, 1), board.getLocationOf(0));
Assert.assertEquals(new XYLocation(0, 2), board.getLocationOf(1));
}
use of aima.core.util.datastructure.XYLocation in project aima-java by aimacode.
the class NQueensBoardTest method testRemoveQueen.
@Test
public void testRemoveQueen() {
board.addQueenAt(new XYLocation(0, 0));
Assert.assertEquals(1, board.getNumberOfQueensOnBoard());
board.removeQueenFrom(new XYLocation(0, 0));
Assert.assertEquals(0, board.getNumberOfQueensOnBoard());
}
use of aima.core.util.datastructure.XYLocation in project aima-java by aimacode.
the class NQueensBoardTest method testEquality.
@Test
public void testEquality() {
board.addQueenAt(new XYLocation(0, 0));
NQueensBoard board2 = new NQueensBoard(8);
board2.addQueenAt(new XYLocation(0, 0));
Assert.assertEquals(board, board2);
NQueensBoard board3 = new NQueensBoard(8);
board3.addQueenAt(new XYLocation(0, 1));
Assert.assertFalse(board.equals(board3));
}
Aggregations