本文整理汇总了Python中solver.Solver.getAllPositions方法的典型用法代码示例。如果您正苦于以下问题:Python Solver.getAllPositions方法的具体用法?Python Solver.getAllPositions怎么用?Python Solver.getAllPositions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类solver.Solver
的用法示例。
在下文中一共展示了Solver.getAllPositions方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: answer
# 需要导入模块: from solver import Solver [as 别名]
# 或者: from solver.Solver import getAllPositions [as 别名]
#Sort the array by number of bricks and get the biggest one, make that the puzzle board.
pieceCollection.sort(key=lambda x: x.size)
puzzle = pieceCollection[-1]
pieceCollection.pop()
#Give each piece a unique number so that the solver won't pick the same piece placed in a different location
# as part of the answer (assumption is that a piece can only be placed once.)
# solver does this by creating a column for each pieces identity.
for i in range (0, len(pieceCollection)):
pieceCollection[i].setIdentity(i)
showPieces()
showPuzzle()
#Instantiate a solver
solver = Solver(pieceCollection, puzzle)
#Build a list of every valid placement of a piece on an empty puzzle board.
solver.getAllPositions(pieceCollection, puzzle)
print "\nSearching for solutions... \n"
solver.buildColumnDictionary()
dictionaries = solver.buildRowDictionary()
solutions = solver.solve(dictionaries[0], dictionaries[1])
solver.showSolutions(list(solutions))