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