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


Python Board.get_piece方法代码示例

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


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

示例1: test_pieces_can_capture_opponent_pieces

# 需要导入模块: from chess.board import Board [as 别名]
# 或者: from chess.board.Board import get_piece [as 别名]
def test_pieces_can_capture_opponent_pieces():
    board = Board(initial_pieces={'a8': King('black'), 'e5': Pawn('black'), 'f3': Knight('white')})
    assert board.pieces_quantity() == 3

    knight = board.get_piece('f3')
    board.move('f3', 'e5')
    assert board.get_piece('e5') is knight
    assert board.pieces_quantity() == 2
开发者ID:deniscostadsc,项目名称:chess,代码行数:10,代码来源:test_board.py

示例2: test_king_can_do_castling_to_left

# 需要导入模块: from chess.board import Board [as 别名]
# 或者: from chess.board.Board import get_piece [as 别名]
def test_king_can_do_castling_to_left():
    board = Board(initial_pieces={'e1': King('white'), 'a1': Rook('white')})
    king = board.get_piece('e1')
    rook = board.get_piece('a1')
    board.move('e1', 'c1')
    assert board.get_piece('c1') == king
    assert board.get_piece('d1') == rook
    assert board.get_piece('e1') is None
    assert board.get_piece('a1') is None
开发者ID:deniscostadsc,项目名称:chess,代码行数:11,代码来源:test_king.py

示例3: test_king_can_moves

# 需要导入模块: from chess.board import Board [as 别名]
# 或者: from chess.board.Board import get_piece [as 别名]
def test_king_can_moves():
    king = King('white')
    #
    # I have to pass a second king because the board look for a second
    # king when you set the first one. Maybe a have to add an attribute
    # to the board class to say wether the match is tutorial or not.
    #
    board = Board(initial_pieces={'f5': king, 'h1': King('black')})
    board.move('f5', 'e5')
    assert board.get_piece('e5') is king
    assert board.get_piece('f5') is None
开发者ID:deniscostadsc,项目名称:chess,代码行数:13,代码来源:test_king.py

示例4: test_pawn_can_moves

# 需要导入模块: from chess.board import Board [as 别名]
# 或者: from chess.board.Board import get_piece [as 别名]
def test_pawn_can_moves():
    board = Board()
    pawn = board.get_piece('e2')
    board.move('e2', 'e3')
    assert board.get_piece('e3') is pawn
    assert board.get_piece('e2') is None
开发者ID:deniscostadsc,项目名称:chess,代码行数:8,代码来源:test_pawn.py

示例5: test_rook_can_moves

# 需要导入模块: from chess.board import Board [as 别名]
# 或者: from chess.board.Board import get_piece [as 别名]
def test_rook_can_moves():
    rook = Rook('white')
    board = Board(initial_pieces={'d5': rook})
    board.move('d5', 'd8')
    assert board.get_piece('d8') is rook
    assert board.get_piece('d5') is None
开发者ID:deniscostadsc,项目名称:chess,代码行数:8,代码来源:test_rook.py

示例6: test_knight_can_moves

# 需要导入模块: from chess.board import Board [as 别名]
# 或者: from chess.board.Board import get_piece [as 别名]
def test_knight_can_moves():
    board = Board()
    knight = board.get_piece('b1')
    board.move('b1', 'c3')
    assert board.get_piece('c3') is knight
    assert board.get_piece('b1') is None
开发者ID:deniscostadsc,项目名称:chess,代码行数:8,代码来源:test_knight.py

示例7: test_bishop_can_moves

# 需要导入模块: from chess.board import Board [as 别名]
# 或者: from chess.board.Board import get_piece [as 别名]
def test_bishop_can_moves():
    bishop = Bishop('White')
    board = Board(initial_pieces={'f1': bishop})
    board.move('f1', 'h3')
    assert board.get_piece('h3') is bishop
    assert board.get_piece('f1') is None
开发者ID:deniscostadsc,项目名称:chess,代码行数:8,代码来源:test_bishop.py


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