Example #1
0
def test_astar_gaschnig_vs_depth_first():
    eight_problem = InstrumentedProblem(
        EightPuzzle(initial=instance_one, goal=goal))
    eight_problem1 = InstrumentedProblem(
        EightPuzzle(initial=instance_one, goal=goal))
    res = astar_search(eight_problem,
                       EightPuzzleExtended(eight_problem).gaschnig_index)
    res1 = depth_first_graph_search(eight_problem1)
    assert res.state == goal
    assert res1.state == goal
    assert eight_problem.explored < eight_problem1.explored
Example #2
0
def test_astar_gaschnig_vs_bidirectional_breadth_first():
    eight_problem = InstrumentedProblem(
        EightPuzzle(initial=instance_one, goal=goal))
    eight_problem1 = EightPuzzle(initial=instance_one, goal=goal)
    inversed_eight_problem = EightPuzzle(initial=goal, goal=instance_one)
    res = astar_search(eight_problem,
                       EightPuzzleExtended(eight_problem).gaschnig_index)
    res1 = instrumented_bidirectional_breadth_first_search(
        eight_problem1, inversed_eight_problem, True)
    assert res.state == goal
    n = res1[0]
    assert n.state == goal
    assert eight_problem.explored > res1[1]
Example #3
0
def test_astar_manhattan_3():
    eight_problem = InstrumentedProblem(
        EightPuzzle(initial=instance_three, goal=goal))
    res = astar_search(eight_problem,
                       EightPuzzleExtended(eight_problem).manhattan_distance)
    assert res.state == goal
Example #4
0
def test_astar_misplaced_tiles_cols_rows_3():
    eight_problem = InstrumentedProblem(
        EightPuzzle(initial=instance_three, goal=goal))
    res = astar_search(eight_problem,
                       EightPuzzleExtended(eight_problem).misplaced_cols_rows)
    assert res.state == goal
Example #5
0
def test_astar_gaschnig_3():
    eight_problem = InstrumentedProblem(
        EightPuzzle(initial=instance_three, goal=goal))
    res = astar_search(eight_problem,
                       EightPuzzleExtended(eight_problem).gaschnig_index)
    assert res.state == goal