コード例 #1
0
        print "Solving by  {0} . . . . . . . . ".format("Block in place(default) Heuristic")
        start = time.time()
        iteration_default, pathlength_default,heapsize_default,visitedstate_default, path_default = game_default.solve()
        time_default = time.time() - start
        print "Time taken: {0} seconds".format(time_default)







    #Generate Report
    if iscustom and isdefault:
        report = Report()
        report.iterations(str(iteration_default), str(-1), str(iteration_custom))
        report.pathlength(str(pathlength_default), str(-1),str(pathlength_custom))
        report.queuesize(str(heapsize_default), str(-1),str(heapsize_custom))
        report.statesvisited(str(visitedstate_default), str(-1),str(visitedstate_custom))
        report.displaystate(initialstate)
        report.displayfilepath()
        report.saveandclose()

    #Saving solution files
    if isdefault:
        k = 1
        inplace_file = open("inplaceblocks_solution.txt","w")
        inplace_file.write("              Solution: In Place Blocks Heuristic \n\n")
        for x in path_default:
            inplace_file.write("________________STATE {0}______________________\n\n".format(str(k)))
            for stack in x.vertex.stacks: