本文整理汇总了Python中piece.Piece.updateMap方法的典型用法代码示例。如果您正苦于以下问题:Python Piece.updateMap方法的具体用法?Python Piece.updateMap怎么用?Python Piece.updateMap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类piece.Piece
的用法示例。
在下文中一共展示了Piece.updateMap方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: answer
# 需要导入模块: from piece import Piece [as 别名]
# 或者: from piece.Piece import updateMap [as 别名]
def answer(state_map, state_piece, x, dx, rad):
map_tmp = copy.deepcopy(const.map)
for i in range(len(state_map)):
if state_map[i] != 0:
map_tmp[state_map[i]][i] = 1
p_tmp = Piece(state_piece, x)
p_tmp.updateMap(map_tmp)
gain = 0
if dx>0:
for i in range(dx):
p_tmp.move('right')
else:
for i in range(-dx):
p_tmp.move('left')
for i in range(rad):
p_tmp.rotate('ccw')
p_tmp.drop()
for i in range(len(p_tmp.shape[0])):
for j in range(len(p_tmp.shape[0][i])):
if p_tmp.shape[0][i][j]:
map_tmp[p_tmp.y+i][p_tmp.x+j] = p_tmp.shape[1]
erasable = []
for i in range(len(map_tmp)-1):
flag_full = True
for j in range(1,len(map_tmp[i])-1):
if map_tmp[i][j] == 0 or map_tmp[i][j] == 8: flag_full = False
if flag_full:
erasable.append(i)
if len(erasable) == 0:
gain = 0
else:
gain = scores[min(len(erasable)-1, 3)]
for i in erasable:
for j in range(i-2):
map_tmp[i-j] = copy.deepcopy(map[i-j-1])
for i in range(len(map_tmp)):
for j in range(len(map_tmp[i])):
if map_tmp[i][j]!=0:
map_tmp[i][j] = 1
return [map_tmp, gain]