本文整理汇总了Python中piece.Piece.rotate_right方法的典型用法代码示例。如果您正苦于以下问题:Python Piece.rotate_right方法的具体用法?Python Piece.rotate_right怎么用?Python Piece.rotate_right使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类piece.Piece
的用法示例。
在下文中一共展示了Piece.rotate_right方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test1
# 需要导入模块: from piece import Piece [as 别名]
# 或者: from piece.Piece import rotate_right [as 别名]
def test1():
b = Board(10,10)
base=Board(data='0,0,0,1,1,1,0,0,0,0;0,0,0,0,0,0,0,0,0,0;0,0,0,0,0,0,0,0,0,0;0,0,0,0,0,0,0,0,0,0;0,0,0,0,0,0,0,0,0,0;0,0,0,0,0,0,0,0,0,0;0,0,0,0,0,0,0,0,0,0;0,0,0,0,0,0,0,0,0,0;0,0,0,0,0,0,0,0,0,0;0,0,0,0,0,0,0,0,0,0;0,0,0,0,0,0,0,0,0,0;0,0,0,0,0,0,0,0,0,0;0,0,0,0,0,0,0,0,0,0;0,0,0,2,2,0,0,0,0,0;0,0,0,0,2,2,0,0,0,0;0,0,0,2,2,0,0,0,0,0;0,0,0,0,2,2,0,0,0,0;0,0,0,0,2,2,0,0,0,0;0,0,0,2,2,2,0,0,0,0;0,0,0,2,2,2,0,0,0,0')
p1 = Piece('I')
p2 = Piece('I')
p2.rotate_right()
loc1 = (0,0)
loc2 = (2,2)
path = b.get_path(p1, loc1, p2, loc2)
result = b.get_feature_vector()
print result
示例2: get_valid_positions
# 需要导入模块: from piece import Piece [as 别名]
# 或者: from piece.Piece import rotate_right [as 别名]
def get_valid_positions(self, piece_type):
valid_positions = []
piece = Piece(piece_type)
for i in range(NUM_ROTATIONS[piece_type]):
blocks = piece.get_locations()
x_blocks, y_blocks = zip(*blocks)
p_minx = min(x_blocks)
p_maxx = max(x_blocks)
p_miny = min(y_blocks)
p_maxy = max(y_blocks)
lowest_blocks = filter(lambda x: x[1] == p_miny, blocks)
# refers to the top left corner of the block (0,0)
for y in range(-p_miny, self.height - p_maxy):
for x in range(-p_minx, self.width - p_maxx):
shift_blocks = map(lambda b: (x + b[0], y + b[1]), blocks)
# finds conflicts of space
conflict = False
for x_block, y_block in shift_blocks:
if self.data[y_block][x_block] > 1:
conflict = True
break
if conflict:
continue
floor_exists = False
for x_block, y_block in shift_blocks:
if y_block == self.height - 1 or self.data[y_block + 1][x_block] > 1:
floor_exists = True
break
if not floor_exists:
continue
valid_positions.append((Piece(piece_type, right_rotations=i), x, y))
piece.rotate_right()
return valid_positions