Search in sources :

Example 1 with PuzzleSolver

use of net.runelite.client.plugins.puzzlesolver.solver.PuzzleSolver in project runelite by runelite.

the class PuzzleSolverOverlay method solve.

private void solve(int[] items) {
    if (solverFuture != null) {
        solverFuture.cancel(true);
    }
    PuzzleState puzzleState = new PuzzleState(items);
    solver = new PuzzleSolver(new IDAStar(new ManhattanDistance()), puzzleState);
    solverFuture = executorService.submit(solver);
}
Also used : IDAStar(net.runelite.client.plugins.puzzlesolver.solver.pathfinding.IDAStar) PuzzleState(net.runelite.client.plugins.puzzlesolver.solver.PuzzleState) PuzzleSolver(net.runelite.client.plugins.puzzlesolver.solver.PuzzleSolver) ManhattanDistance(net.runelite.client.plugins.puzzlesolver.solver.heuristics.ManhattanDistance)

Example 2 with PuzzleSolver

use of net.runelite.client.plugins.puzzlesolver.solver.PuzzleSolver in project runelite by runelite.

the class PuzzleSolverTest method testSolver.

@Test
public void testSolver() {
    for (PuzzleState state : START_STATES) {
        PuzzleSolver solver = new PuzzleSolver(new IDAStar(new ManhattanDistance()), state);
        solver.run();
        assertTrue(solver.hasSolution());
        assertFalse(solver.hasFailed());
        assertTrue(solver.getStep(solver.getStepCount() - 1).hasPieces(FINISHED_STATE));
    }
}
Also used : IDAStar(net.runelite.client.plugins.puzzlesolver.solver.pathfinding.IDAStar) PuzzleState(net.runelite.client.plugins.puzzlesolver.solver.PuzzleState) PuzzleSolver(net.runelite.client.plugins.puzzlesolver.solver.PuzzleSolver) ManhattanDistance(net.runelite.client.plugins.puzzlesolver.solver.heuristics.ManhattanDistance) Test(org.junit.Test)

Aggregations

PuzzleSolver (net.runelite.client.plugins.puzzlesolver.solver.PuzzleSolver)2 PuzzleState (net.runelite.client.plugins.puzzlesolver.solver.PuzzleState)2 ManhattanDistance (net.runelite.client.plugins.puzzlesolver.solver.heuristics.ManhattanDistance)2 IDAStar (net.runelite.client.plugins.puzzlesolver.solver.pathfinding.IDAStar)2 Test (org.junit.Test)1