本文整理汇总了Python中chess.Board.san方法的典型用法代码示例。如果您正苦于以下问题:Python Board.san方法的具体用法?Python Board.san怎么用?Python Board.san使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类chess.Board
的用法示例。
在下文中一共展示了Board.san方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: display_move_on_clock
# 需要导入模块: from chess import Board [as 别名]
# 或者: from chess.Board import san [as 别名]
def display_move_on_clock(self, move, fen, side, beep=False, left_dots=0, right_dots=0):
bit_board = Board(fen)
move_text = bit_board.san(move)
if side == ClockSide.RIGHT:
move_text = move_text.rjust(11)
text = self.dgttranslate.move(move_text)
self._display_on_dgt_pi(text, beep, left_dots, right_dots)
示例2: pv_to_san
# 需要导入模块: from chess import Board [as 别名]
# 或者: from chess.Board import san [as 别名]
def pv_to_san(self):
if(self.san_arr == None):
return ""
else:
try:
pv_san = []
board = Board(self.san_arr[0])
moves = self.san_arr[1]
for uci in moves:
move = Move.from_uci(uci)
if(move in board.pseudo_legal_moves):
pv_san.append(board.san(move))
board.push(move)
if(len(pv_san) > 0):
s = ""
white_moves = True
move_no = (self.no_game_halfmoves//2)+1
if(self.no_game_halfmoves % 2 == 1):
white_moves = False
s += str(move_no)+". ... "
move_no += 1
for san in pv_san:
if(white_moves):
s += " "+str(move_no)+". "+san
move_no +=1
else:
s += " "+san
white_moves = not white_moves
return s
else:
return ""
except ValueError:
return ""
示例3: display_move_on_clock
# 需要导入模块: from chess import Board [as 别名]
# 或者: from chess.Board import san [as 别名]
def display_move_on_clock(self, move, fen, beep=False):
if self.enable_dgt_3000:
bit_board = Board(fen)
text = self.dgttranslate.move(bit_board.san(move))
self._display_on_dgt_3000(text, beep)
else:
text = ' ' + move.uci()
self._display_on_dgt_xl(text, beep)
示例4: display_move_on_clock
# 需要导入模块: from chess import Board [as 别名]
# 或者: from chess.Board import san [as 别名]
def display_move_on_clock(self, move, fen, beep=BeepLevel.CONFIG):
beep = self.get_beep_level(beep)
if self.enable_dgt_3000:
bit_board = Board(fen)
text = bit_board.san(move)
self._display_on_dgt_3000(text, beep)
else:
text = ' ' + move.uci()
self._display_on_dgt_xl(text, beep)
示例5: visit_move
# 需要导入模块: from chess import Board [as 别名]
# 或者: from chess.Board import san [as 别名]
def visit_move(self, board: chess.Board, move: chess.Move) -> None:
if self.variations or not self.variation_depth:
# Write the move number.
if board.turn == chess.WHITE:
self.write_token(str(board.fullmove_number) + ". ")
elif self.force_movenumber:
self.write_token(str(board.fullmove_number) + "... ")
# Write the SAN.
self.write_token(board.san(move) + " ")
self.force_movenumber = False
示例6: display_move_on_clock
# 需要导入模块: from chess import Board [as 别名]
# 或者: from chess.Board import san [as 别名]
def display_move_on_clock(self, move, fen, side, beep=False, left_dots=0, right_dots=0):
if self.enable_dgt_3000:
bit_board = Board(fen)
move_text = bit_board.san(move)
if side == ClockSide.RIGHT:
move_text = move_text.rjust(8)
text = self.dgttranslate.move(move_text)
self._display_on_dgt_3000(text, beep, left_dots, right_dots)
else:
move_text = move.uci()
if side == ClockSide.RIGHT:
move_text = move_text.rjust(6)
self._display_on_dgt_xl(move_text, beep, left_dots, right_dots)
示例7: display_move_on_clock
# 需要导入模块: from chess import Board [as 别名]
# 或者: from chess.Board import san [as 别名]
def display_move_on_clock(self, message):
left_dots = message.ld if hasattr(message, 'ld') else ClockDots.NONE
right_dots = message.rd if hasattr(message, 'rd') else ClockDots.NONE
display_m = self.enable_dgt_3000 and not self.dgtserial.enable_revelation_leds
if display_m:
bit_board = Board(message.fen)
move_text = bit_board.san(message.move)
if message.side == ClockSide.RIGHT:
move_text = move_text.rjust(8)
text = self.dgttranslate.move(move_text)
self._display_on_dgt_3000(text, message.beep, left_dots, right_dots)
else:
move_text = message.move.uci()
if message.side == ClockSide.RIGHT:
move_text = move_text.rjust(6)
self._display_on_dgt_xl(move_text, message.beep, left_dots, right_dots)
示例8: get_san
# 需要导入模块: from chess import Board [as 别名]
# 或者: from chess.Board import san [as 别名]
def get_san(self, message, is_xl=False):
"""Create a chess.board plus a text ready to display on clock."""
def move(text: str, language: str, capital: bool, short: bool):
"""Return move text for clock display."""
if short:
directory = {}
if language == 'de':
directory = {'R': 'T', 'N': 'S', 'B': 'L', 'Q': 'D'}
if language == 'nl':
directory = {'R': 'T', 'N': 'P', 'B': 'L', 'Q': 'D'}
if language == 'fr':
directory = {'R': 'T', 'N': 'C', 'B': 'F', 'Q': 'D', 'K': '@'}
if language == 'es':
directory = {'R': 'T', 'N': 'C', 'B': 'A', 'Q': 'D', 'K': '@'}
if language == 'it':
directory = {'R': 'T', 'N': 'C', 'B': 'A', 'Q': 'D', 'K': '@'}
for i, j in directory.items():
text = text.replace(i, j)
text = text.replace('@', 'R') # replace the King "@" from fr, es, it languages
if capital:
return text.upper()
else:
return text
bit_board = Board(message.fen, chess960=message.uci960)
if bit_board.is_legal(message.move):
if message.long:
move_text = message.move.uci()
else:
move_text = bit_board.san(message.move)
else:
logging.warning('[%s] illegal move %s found - uci960: %s fen: %s', self.get_name(), message.move,
message.uci960, message.fen)
move_text = 'er{}' if is_xl else 'err {}'
move_text = move_text.format(message.move.uci()[:4])
if message.side == ClockSide.RIGHT:
move_text = move_text.rjust(6 if is_xl else 8)
return bit_board, move(move_text, message.lang, message.capital and not is_xl, not message.long)
示例9: display_move_on_clock
# 需要导入模块: from chess import Board [as 别名]
# 或者: from chess.Board import san [as 别名]
def display_move_on_clock(self, move, fen, beep=BeepLevel.CONFIG):
beep = self.get_beep_level(beep)
bit_board = Board(fen)
text = bit_board.san(move)
self._display_on_dgt_pi(text, beep)
示例10: display_move_on_clock
# 需要导入模块: from chess import Board [as 别名]
# 或者: from chess.Board import san [as 别名]
def display_move_on_clock(self, move, fen, beep=False):
bit_board = Board(fen)
text = self.dgttranslate.move(bit_board.san(move))
self._display_on_dgt_pi(text, beep)