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


Python Board.current_king_position方法代码示例

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


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

示例1: test_current_king_position_black

# 需要导入模块: from cython.importer import Board [as 别名]
# 或者: from cython.importer.Board import current_king_position [as 别名]
 def test_current_king_position_black(self):
     board = Board(True)
     board.load_fen(
             "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR b KQkq - 0 1")
     self.assertEqual(board.current_king_position(), (4, 7))
开发者ID:GRUPO-ES2-GJLRT,项目名称:XADREZ_ES2,代码行数:7,代码来源:test_board.py

示例2: Chess

# 需要导入模块: from cython.importer import Board [as 别名]
# 或者: from cython.importer.Board import current_king_position [as 别名]

#.........这里部分代码省略.........
            self.verify_status(self.board.status(None))
            
            return True
        self.selected = selected
        self.fail = square
        self.do_jit_draw()
        self.snap_board.dynamic()
        self.do_jit_draw()
        return False

    def do_move(self, selected, square, promotion=5):
        return self.board.move(selected, square, promotion)

    def change_turn(self, selected, square):
        opening = ''.join([
            p0x88_to_chess_notation(tuple_to_0x88(selected)),
            p0x88_to_chess_notation(tuple_to_0x88(square))
        ])
        self.selected = None
        self.fail = None

        if hasattr(self.current_player, 'openings'):
            if self.current_player.openings:
                try:
                    self.current_player.openings = self.current_player.openings[opening]
                except KeyError:
                    self.current_player.openings = {}

        self.other_player.end_turn()
        self.current_player.start_turn()

    def verify_status(self, status):
        if status == CHECK:
            self.check = self.board.current_king_position()
            self.countdown = CHECK_COUNTDOWN
        elif status == CHECKMATE:
            self.current_player.lose()
            return True
        elif status == STALEMATE:
            self.end_game(GAME_DRAW)
            return True
        elif status == FIFTY_MOVE:
            if self.fifty_move == FIFTY_MOVE_OPTIONS["auto"]:
                self.end_game(GAME_DRAW)
                return True
        return False

    def win(self, color):
        self.end_game(WINS[color])

    def end_game(self, state):
        self.finished = True
        for player in self.players.values():
            player.state = END
        self.state = state
        for threaded_event in self.thread_events:
            threaded_event.set()
        self.game.scene = EndMenu(game=self.game, chess=self)

    def resize(self):
        ChessInterface.resize(self)

    def pause(self):
        self.previous_state = self.state
        self.state = PAUSE
        self.current_player.pause_turn()
开发者ID:GRUPO-ES2-GJLRT,项目名称:XADREZ_ES2,代码行数:70,代码来源:chess.py

示例3: test_current_king_position_white

# 需要导入模块: from cython.importer import Board [as 别名]
# 或者: from cython.importer.Board import current_king_position [as 别名]
 def test_current_king_position_white(self):
     board = Board(True)
     self.assertEqual(board.current_king_position(), (4, 0))
开发者ID:GRUPO-ES2-GJLRT,项目名称:XADREZ_ES2,代码行数:5,代码来源:test_board.py


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