本文整理汇总了Python中level.Level.load_from_file方法的典型用法代码示例。如果您正苦于以下问题:Python Level.load_from_file方法的具体用法?Python Level.load_from_file怎么用?Python Level.load_from_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类level.Level
的用法示例。
在下文中一共展示了Level.load_from_file方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: solve_file
# 需要导入模块: from level import Level [as 别名]
# 或者: from level.Level import load_from_file [as 别名]
def solve_file(path, dist=False):
print("Reading level from", path)
level = Level()
level.load_from_file(path)
print("Generating clauses ...")
clauses = sat_get_clauses(level, dist)
print("Got %d clauses" % len(clauses))
pathparts = splitext(path)
pathin = "%s.sat_in%s" % pathparts
pathout = "%s.sat_out%s" % pathparts
pathsol = "%s.sol.png" % pathparts[0]
print("Writing to file ...")
map = sat_write_clauses(clauses, pathin)
# Release some memory
clauses = []
collect()
print("Running SAT solver ...")
call([SAT_PATH, pathin, pathout])
print("Reading valuation ...")
val = sat_read_valuation(level, map, pathout)
if not val:
print("Unsatisfiable ...")
return
# pprint(val)
print("Displaying solution ...")
img = get_solution(level, val, dist)
img.show()
img.save(pathsol)