本文整理汇总了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:
示例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)
示例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)
示例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)
示例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)
示例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)