public void testIterativeDeepeningAStar() { try { IterativeDeepeningAStar<HState> test = new IterativeDeepeningAStar<HState>(null); fail("creating a search without a problem should fail!"); test.run(); } catch (Exception e) { } }
public void testRun() { emptySearch.run(); assertTrue( String.format("%d != null", emptySearch.getResult()), emptySearch.getResult() == null); assertTrue(String.format("%d != 0", emptySearch.neededSteps()), emptySearch.neededSteps() == 0); // assertTrue(String.format("%d != // 0",emptySearch.branchedNodes()),emptySearch.branchedNodes()==0); assertTrue(empty.getOrder().isEmpty()); walkSearch.run(); // System.out.println(walk.getOrder().toString()); assertTrue(String.format("%d != null", runSearch.getResult()), walkSearch.getResult() == null); assertTrue( String.format("%d != 357", walkSearch.neededSteps()), walkSearch.neededSteps() == 357); // assertTrue(walkSearch.branchedNodes()==walkSearch.neededSteps()); assertTrue( walk.getOrder() .equals( Arrays.asList( 0, 1, 2, 3, 4, 9, 14, 19, 24, 8, 13, 18, 23, 7, 12, 17, 22, 6, 11, 16, 21, 5, 10, 15, 20))); // secound try to show that its deterministic walkSearch.run(); assertTrue(String.format("%d != null", runSearch.getResult()), walkSearch.getResult() == null); assertTrue( String.format("%d != 357", walkSearch.neededSteps()), walkSearch.neededSteps() == 357); // assertTrue(walkSearch.branchedNodes()==walkSearch.neededSteps()); assertTrue( walk.getOrder() .equals( Arrays.asList( 0, 1, 2, 3, 4, 9, 14, 19, 24, 8, 13, 18, 23, 7, 12, 17, 22, 6, 11, 16, 21, 5, 10, 15, 20))); runSearch.run(); // System.out.println(run.getOrder().toString()); assertFalse(String.format("%s != null", runSearch.getResult()), runSearch.getResult() == null); // System.out.println(runSearch.getResult().getPath().toString()); assertTrue(String.format("%d != 24", runSearch.getResult().id), runSearch.getResult().id == 24); assertTrue( runSearch.getResult().getPath().equals(Arrays.asList(24, 19, 18, 13, 12, 7, 2, 1, 0))); assertTrue(String.format("%d != 57", runSearch.neededSteps()), runSearch.neededSteps() == 57); // assertTrue(runSearch.branchedNodes()==runSearch.neededSteps()); assertTrue(run.getOrder().equals(Arrays.asList(0, 1, 2, 3, 7, 8, 12, 13, 18, 19))); // secound try to show that its deterministic runSearch.run(); assertFalse(String.format("%s != null", runSearch.getResult()), runSearch.getResult() == null); assertTrue(String.format("%d != 24", runSearch.getResult().id), runSearch.getResult().id == 24); assertTrue( runSearch.getResult().getPath().equals(Arrays.asList(24, 19, 18, 13, 12, 7, 2, 1, 0))); assertTrue(String.format("%d != 57", runSearch.neededSteps()), runSearch.neededSteps() == 57); // assertTrue(runSearch.branchedNodes()==runSearch.neededSteps()); assertTrue(run.getOrder().equals(Arrays.asList(0, 1, 2, 3, 7, 8, 12, 13, 18, 19))); stopSearch.run(); // System.out.println(stop.getOrder().toString()); assertTrue(String.format("%s != null", runSearch.getResult()), stopSearch.getResult() == null); assertTrue(String.format("%d != 5", stopSearch.neededSteps()), stopSearch.neededSteps() == 5); // assertTrue(stopSearch.branchedNodes()==stopSearch.neededSteps()); assertTrue(stop.getOrder().equals(Arrays.asList(0, 1, 6, 5))); nohashSearch.run(); // System.out.println(nohash.getOrder().toString()); assertTrue( String.format("%d != null", nohashSearch.getResult()), nohashSearch.getResult() == null); assertTrue( String.format("%d != 3343", nohashSearch.neededSteps()), nohashSearch.neededSteps() == 3343); // assertTrue(walkSearch.branchedNodes()==walkSearch.neededSteps()); assertTrue( nohash .getOrder() .equals( Arrays.asList( 0, 1, 2, 3, 4, 9, 14, 19, 24, 8, 9, 14, 19, 24, 13, 14, 19, 24, 18, 19, 24, 23, 24, 7, 8, 9, 14, 19, 24, 13, 14, 19, 24, 18, 19, 24, 23, 24, 12, 13, 14, 19, 24, 18, 19, 24, 23, 24, 17, 18, 19, 24, 23, 24, 22, 23, 24, 6, 7, 8, 9, 14, 19, 24, 13, 14, 19, 24, 18, 19, 24, 23, 24, 12, 13, 14, 19, 24, 18, 19, 24, 23, 24, 17, 18, 19, 24, 23, 24, 22, 23, 24, 11, 12, 13, 14, 19, 24, 18, 19, 24, 23, 24, 17, 18, 19, 24, 23, 24, 22, 23, 24, 16, 17, 18, 19, 24, 23, 24, 22, 23, 24, 21, 22, 23, 24, 5, 6, 7, 8, 9, 14, 19, 24, 13, 14, 19, 24, 18, 19, 24, 23, 24, 12, 13, 14, 19, 24, 18, 19, 24, 23, 24, 17, 18, 19, 24, 23, 24, 22, 23, 24, 11, 12, 13, 14, 19, 24, 18, 19, 24, 23, 24, 17, 18, 19, 24, 23, 24, 22, 23, 24, 16, 17, 18, 19, 24, 23, 24, 22, 23, 24, 21, 22, 23, 24, 10, 11, 12, 13, 14, 19, 24, 18, 19, 24, 23, 24, 17, 18, 19, 24, 23, 24, 22, 23, 24, 16, 17, 18, 19, 24, 23, 24, 22, 23, 24, 21, 22, 23, 24, 15, 16, 17, 18, 19, 24, 23, 24, 22, 23, 24, 21, 22, 23, 24, 20, 21, 22, 23, 24))); // secound try to show that its deterministic nohashSearch.run(); assertTrue( String.format("%d != null", nohashSearch.getResult()), nohashSearch.getResult() == null); assertTrue( String.format("%d != 3343", nohashSearch.neededSteps()), nohashSearch.neededSteps() == 3343); // assertTrue(walkSearch.branchedNodes()==walkSearch.neededSteps()); assertTrue( nohash .getOrder() .equals( Arrays.asList( 0, 1, 2, 3, 4, 9, 14, 19, 24, 8, 9, 14, 19, 24, 13, 14, 19, 24, 18, 19, 24, 23, 24, 7, 8, 9, 14, 19, 24, 13, 14, 19, 24, 18, 19, 24, 23, 24, 12, 13, 14, 19, 24, 18, 19, 24, 23, 24, 17, 18, 19, 24, 23, 24, 22, 23, 24, 6, 7, 8, 9, 14, 19, 24, 13, 14, 19, 24, 18, 19, 24, 23, 24, 12, 13, 14, 19, 24, 18, 19, 24, 23, 24, 17, 18, 19, 24, 23, 24, 22, 23, 24, 11, 12, 13, 14, 19, 24, 18, 19, 24, 23, 24, 17, 18, 19, 24, 23, 24, 22, 23, 24, 16, 17, 18, 19, 24, 23, 24, 22, 23, 24, 21, 22, 23, 24, 5, 6, 7, 8, 9, 14, 19, 24, 13, 14, 19, 24, 18, 19, 24, 23, 24, 12, 13, 14, 19, 24, 18, 19, 24, 23, 24, 17, 18, 19, 24, 23, 24, 22, 23, 24, 11, 12, 13, 14, 19, 24, 18, 19, 24, 23, 24, 17, 18, 19, 24, 23, 24, 22, 23, 24, 16, 17, 18, 19, 24, 23, 24, 22, 23, 24, 21, 22, 23, 24, 10, 11, 12, 13, 14, 19, 24, 18, 19, 24, 23, 24, 17, 18, 19, 24, 23, 24, 22, 23, 24, 16, 17, 18, 19, 24, 23, 24, 22, 23, 24, 21, 22, 23, 24, 15, 16, 17, 18, 19, 24, 23, 24, 22, 23, 24, 21, 22, 23, 24, 20, 21, 22, 23, 24))); }