当前位置: 首页>>代码示例>>Python>>正文


Python Piece.block方法代码示例

本文整理汇总了Python中piece.Piece.block方法的典型用法代码示例。如果您正苦于以下问题:Python Piece.block方法的具体用法?Python Piece.block怎么用?Python Piece.block使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在piece.Piece的用法示例。


在下文中一共展示了Piece.block方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: add_piece

# 需要导入模块: from piece import Piece [as 别名]
# 或者: from piece.Piece import block [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
开发者ID:bobev18,项目名称:py3chess,代码行数:40,代码来源:board.py


注:本文中的piece.Piece.block方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。