本文整理汇总了Python中cube.Cube.cw_neighbor_corners方法的典型用法代码示例。如果您正苦于以下问题:Python Cube.cw_neighbor_corners方法的具体用法?Python Cube.cw_neighbor_corners怎么用?Python Cube.cw_neighbor_corners使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cube.Cube
的用法示例。
在下文中一共展示了Cube.cw_neighbor_corners方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: find_unsolved
# 需要导入模块: from cube import Cube [as 别名]
# 或者: from cube.Cube import cw_neighbor_corners [as 别名]
def find_unsolved(self, cube, print_debug=False):
unsolved = []
for dest_edge, dest_edge2 in Cube.cw_corners_on_face('up'):
#print dest_edge, dest_edge2
if cube.get_color('up', dest_edge, dest_edge2) != 'yellow':
corner_neighbors = Cube.cw_neighbor_corners(
('up', dest_edge, dest_edge2))
#print corner_neighbors
colors = [cube.get_color(face, edge, edge2)
for face, edge, edge2 in corner_neighbors]
#print colors
yellow_index = colors.index('yellow')
assert yellow_index == 1 or yellow_index == 2
yellow_corner = corner_neighbors[yellow_index]
unsolved.append(Unsolved(
yellow_corner[0], yellow_corner[1], yellow_corner[2],
'up', dest_edge, dest_edge2))
return unsolved
示例2: solve_case
# 需要导入模块: from cube import Cube [as 别名]
# 或者: from cube.Cube import cw_neighbor_corners [as 别名]
def solve_case(self, cube, unsolved, print_debug=False):
case = unsolved[0]
if print_debug: print "DEBUG: case = " + str(case)
source_cubie = (case.source_face, case.source_edge, case.source_edge2)
if cube.is_cubie_in_layer(source_cubie, 'up'):
corner_neighbors = Cube.cw_neighbor_corners(source_cubie)
upper_corners = [c for c in corner_neighbors if c[0] == 'up']
assert (len(upper_corners) == 1)
upper_corner = upper_corners[0]
setup_move = cube.get_simple_move_corners(
'up', (upper_corner[1], upper_corner[2]), \
(case.dest_edge, case.dest_edge2))
times = setup_move[1]
if times != 0:
if print_debug: print "DEBUG: returning setup_move " + str([setup_move])
return [setup_move]
upper_corner_index = corner_neighbors.index(upper_corner)
if upper_corner_index == 0:
edge_below = tuple([f for f in source_cubie if f != 'up'])
assert len(edge_below) == 2
setup_sequence = cube.get_move_cubie_into_layer(edge_below, 'up')
if print_debug: print "DEBUG: edge_below = {0}, setup_sequence = {1}".format(edge_below, setup_sequence)
steps = setup_sequence + [('up', 2)] + \
Solver.reverse_sequence(setup_sequence)
elif upper_corner_index == 1:
steps = [(case.source_face, 3), ('up', 3), (case.source_face, 1)]
elif upper_corner_index == 2:
steps = [(case.source_face, 1), ('up', 1), (case.source_face, 3)]
else:
raise Exception("upper_corner_index should be 0, 1, or 2")
if print_debug: print "DEBUG: returning upper_corner_index " + str(upper_corner_index) + ", steps = " + str(steps)
return steps
else:
setup_sequence = cube.get_move_cubie_into_layer(source_cubie, 'up')
if print_debug: print "DEBUG: setup_sequence = " + str(setup_sequence)
steps = setup_sequence + [('up', 1)] + \
Solver.reverse_sequence(setup_sequence)
if print_debug: print "DEBUG: returning steps = " + str(steps)
return steps