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


Python Board.status方法代码示例

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


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

示例1: Chess

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

#.........这里部分代码省略.........
            sys.exit()

        if event.type == MOUSEBUTTONUP:
            if self.current_player.state == END:
                return
            square = self.get_square(event.pos)
            self.current_player.click(square)
            self.main_div.click(event.pos)
            self.do_jit_draw()
        elif event.type == MOUSEMOTION:
            self.main_div.motion(event.pos)
        elif event.type == KEYDOWN:
            if event.key == K_ESCAPE:
                self.pause()

    def select(self, square):
        self.snap_board.dynamic()
        self.selected = square
        self.do_jit_draw()

    def play(self, square, promotion=5):
        selected = self.selected
        self.selected = None
        self.fail = None
        self.check = None
        self.snap_board.dynamic()
        self.do_jit_draw()
        self.snap_board.snap()
        movement = self.do_move(selected, square, promotion)
        if movement:
            self.snap_board.dynamic()
            self.do_jit_draw()
            self.change_turn(selected, square)
            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:
开发者ID:GRUPO-ES2-GJLRT,项目名称:XADREZ_ES2,代码行数:70,代码来源:chess.py

示例2: test_normal_status

# 需要导入模块: from cython.importer import Board [as 别名]
# 或者: from cython.importer.Board import status [as 别名]
 def test_normal_status(self):
     board = Board(False)
     board.load_fen("7k/8/8/8/8/8/8/8 b kQkq - 0 1")
     self.assertEqual(board.status(None), NORMAL)
开发者ID:GRUPO-ES2-GJLRT,项目名称:XADREZ_ES2,代码行数:6,代码来源:test_board.py

示例3: test_fifty_move_status

# 需要导入模块: from cython.importer import Board [as 别名]
# 或者: from cython.importer.Board import status [as 别名]
 def test_fifty_move_status(self):
     board = Board(False)
     board.load_fen("7k/8/8/8/8/8/8/8 b kQkq - 50 50")
     self.assertEqual(board.status(None), FIFTY_MOVE)
开发者ID:GRUPO-ES2-GJLRT,项目名称:XADREZ_ES2,代码行数:6,代码来源:test_board.py

示例4: test_stalemate_status

# 需要导入模块: from cython.importer import Board [as 别名]
# 或者: from cython.importer.Board import status [as 别名]
 def test_stalemate_status(self):
     board = Board(False)
     board.load_fen("7k/5K2/6Q1/8/8/8/8/8 b kQkq - 0 1")
     self.assertEqual(board.status(None), STALEMATE)
开发者ID:GRUPO-ES2-GJLRT,项目名称:XADREZ_ES2,代码行数:6,代码来源:test_board.py

示例5: test_checkmate_status

# 需要导入模块: from cython.importer import Board [as 别名]
# 或者: from cython.importer.Board import status [as 别名]
 def test_checkmate_status(self):
     board = Board(False)
     board.load_fen("8/4k3/8/3RRR2/8/8/8/8 b kQkq - 0 1")
     self.assertEqual(board.status(None), CHECKMATE)
开发者ID:GRUPO-ES2-GJLRT,项目名称:XADREZ_ES2,代码行数:6,代码来源:test_board.py

示例6: test_check_status

# 需要导入模块: from cython.importer import Board [as 别名]
# 或者: from cython.importer.Board import status [as 别名]
 def test_check_status(self):
     board = Board(False)
     board.load_fen("4k3/8/8/4R3/8/8/8/8 b kQkq - 0 1")
     self.assertEqual(board.status(None), CHECK)
开发者ID:GRUPO-ES2-GJLRT,项目名称:XADREZ_ES2,代码行数:6,代码来源:test_board.py


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