本文整理汇总了Python中piece.Piece.update_heat方法的典型用法代码示例。如果您正苦于以下问题:Python Piece.update_heat方法的具体用法?Python Piece.update_heat怎么用?Python Piece.update_heat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类piece.Piece
的用法示例。
在下文中一共展示了Piece.update_heat方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_piece
# 需要导入模块: from piece import Piece [as 别名]
# 或者: from piece.Piece import update_heat [as 别名]
def add_piece(self, color, type_=None, location=None, not_spawn=True):
if isinstance(color, Piece):
new_piece = color
location = new_piece.location
else:
try: # for [email protected]
type_ = color[1]
location = color[-2:]
color = color[0]
except IndexError:
pass
if self.state[location]:
message = 'Are you blind - there is another piece at that spot: ' + repr(self.state[location])
raise MoveException(message)
new_piece = Piece(self, color, type_, location)
self.state[location] = new_piece
affected = self.find_blockers(location) # note that determining affected pieces should be after making chage to the self.state !!!
for affectee in affected:
new_piece.block(*affectee)
self.state[affectee[0]].block(location, neggate_direction(affectee[1]))
if not_spawn:
self.state[affectee[0]].update_heat()
self.all.append(new_piece)
if new_piece.color == 'w':
self.white.append(new_piece)
else:
self.black.append(new_piece)
index = BOARD_KEY_INDEX[location]
self.hashstate = self.hashstate[:index] + new_piece.hashtype + self.hashstate[index+1:]
# return set(affected).union([new_piece])
# return set([new_piece]) # ??? to cause heat update?
if not_spawn:
new_piece.update_heat() # the actor piece heat can be updated here