use of aima.core.util.datastructure.XYLocation in project aima-java by aimacode.
the class NQueensBoardTest method testMultipleQueens.
@Test
public void testMultipleQueens() {
XYLocation loc1 = new XYLocation(3, 3);
board.addQueenAt(loc1);
Assert.assertEquals(1, board.getNumberOfAttacksOn(loc1.right()));
board.addQueenAt(loc1.right().right());
Assert.assertEquals(1, board.getNumberOfAttacksOn(loc1));
Assert.assertEquals(2, board.getNumberOfAttacksOn(loc1.right()));
board.addQueenAt(loc1.right().down());
Assert.assertEquals(2, board.getNumberOfAttacksOn(loc1));
Assert.assertEquals(3, board.getNumberOfAttacksOn(loc1.right()));
Assert.assertEquals(2, board.getNumberOfAttacksOn(loc1.right().right()));
}
use of aima.core.util.datastructure.XYLocation in project aima-java by aimacode.
the class NQueensBoardTest method testDontPlaceTwoQueensOnOneSquare.
@Test
public void testDontPlaceTwoQueensOnOneSquare() {
board.addQueenAt(new XYLocation(0, 0));
board.addQueenAt(new XYLocation(0, 0));
Assert.assertEquals(1, board.getNumberOfQueensOnBoard());
}
use of aima.core.util.datastructure.XYLocation in project aima-java by aimacode.
the class NQueensBoardTest method testAttack2.
@Test
public void testAttack2() {
board.addQueenAt(new XYLocation(7, 0));
Assert.assertEquals(true, board.isSquareUnderAttack(new XYLocation(6, 1)));
}
use of aima.core.util.datastructure.XYLocation in project aima-java by aimacode.
the class TicTacToeApp method proposeMove.
/** Uses adversarial search for selecting the next action. */
private void proposeMove() {
AdversarialSearch<TicTacToeState, XYLocation> search;
XYLocation action;
switch(strategyCombo.getSelectionModel().getSelectedIndex()) {
case 0:
search = MinimaxSearch.createFor(game);
break;
case 1:
search = AlphaBetaSearch.createFor(game);
break;
case 2:
search = IterativeDeepeningAlphaBetaSearch.createFor(game, 0.0, 1.0, 1000);
break;
default:
search = IterativeDeepeningAlphaBetaSearch.createFor(game, 0.0, 1.0, 1000);
((IterativeDeepeningAlphaBetaSearch<?, ?, ?>) search).setLogEnabled(true);
}
action = search.makeDecision(currState);
searchMetrics = search.getMetrics();
currState = game.getResult(currState, action);
update();
}
use of aima.core.util.datastructure.XYLocation in project aima-java by aimacode.
the class EightPuzzleBoard method getPositions.
public List<XYLocation> getPositions() {
ArrayList<XYLocation> retVal = new ArrayList<>();
for (int i = 0; i < 9; i++) {
int absPos = getPositionOf(i);
XYLocation loc = new XYLocation(getXCoord(absPos), getYCoord(absPos));
retVal.add(loc);
}
return retVal;
}
Aggregations