Exemplo n.º 1
0
def runAStar():
    initial_state = puzzle.CREATE_INITIAL_STATE()
    print("Initial State:")
    print(Problem.DESCRIBE_STATE(initial_state))
    global COUNT, BACKLINKS
    COUNT = 0
    BACKLINKS = {}
    IterativeAStar(initial_state)
    print(str(COUNT) + " states examined.")
Exemplo n.º 2
0
def runDFS():
    initial_state = Problem.CREATE_INITIAL_STATE()
    print("Initial State:")
    print(Problem.DESCRIBE_STATE(initial_state))
    global COUNT, BACKLINKS, start
    COUNT = 0
    BACKLINKS = {}
    start = time.time()
    IterativeDFS(initial_state)
    print(str(COUNT) + " states examined.")
Exemplo n.º 3
0
def backtrace(S):
    global BACKLINKS

    path = []
    while not S == -1:
        path.append(S)
        S = BACKLINKS[Problem.HASHCODE(S)]
    path.reverse()
    print("Solution path: ")
    for s in path:
        print(Problem.DESCRIBE_STATE(s))
    return path
Exemplo n.º 4
0
def runDFS():
    initial_state = Problem.CREATE_INITIAL_STATE()
    print("Initial State:")
    print(Problem.DESCRIBE_STATE(initial_state))
    global COUNT, BACKLINKS
    COUNT = 0
    BACKLINKS = {}
    # num = 0
    # true = 0
    # tOps = []
    # for op in Problem.OPERATORS:
    #     print(op.name, op.precond(initial_state))
    #     if op.precond(initial_state):
    #         true += 1
    #         tOps.append(op.name)
    #     num+=1
    # print(num, true)
    # for x in tOps:
    #     print(x)
    # input()
    print(50)
    ItrBreadthFS(initial_state)
    print(52)
    print(str(COUNT) + " states examined.")