本文整理汇总了Python中cube.Cube.generate_scramble_sequence方法的典型用法代码示例。如果您正苦于以下问题:Python Cube.generate_scramble_sequence方法的具体用法?Python Cube.generate_scramble_sequence怎么用?Python Cube.generate_scramble_sequence使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cube.Cube
的用法示例。
在下文中一共展示了Cube.generate_scramble_sequence方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: range
# 需要导入模块: from cube import Cube [as 别名]
# 或者: from cube.Cube import generate_scramble_sequence [as 别名]
from cube import Cube
from solver import Solver
import random
num_trials = 1000
scramble_moves_per_trial = 100
results = []
successes = 0
attempts = 0
for i in range(1, num_trials + 1):
cube = Cube()
scramble = cube.generate_scramble_sequence(
moves=scramble_moves_per_trial, seed=i)
cube.apply_sequence(scramble)
result = ""
if cube.is_solved():
result += "NOTE: cube was already solved! "
solution = Solver().find_solution(cube)
attempts += 1
cube.apply_sequence(solution)
success = cube.is_solved()
if success:
result += "Successfully solved!"
successes += 1
示例2: run_sequence
# 需要导入模块: from cube import Cube [as 别名]
# 或者: from cube.Cube import generate_scramble_sequence [as 别名]
import graphics
from cube import Cube
from solver import Solver
def run_sequence(sequence, cube, display):
for move in sequence:
display.wait_for_key()
face, times = move
cube.rotate(face, times)
display.draw()
display.wait_for_key()
cube = Cube()
display = graphics.CubeDisplay(cube)
sequence = cube.generate_scramble_sequence(moves=10, seed=710)
print 'Scrambling sequence: ' + str(sequence)
run_sequence(sequence, cube, display)
solution = Solver(debug_display=display, print_debug=True).find_solution(cube)
print 'Solution sequence: ' + str(solution)
run_sequence(solution, cube, display)
display.wait_until_quit()