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


Python Board.at方法代码示例

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


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

示例1: test_normal_move

# 需要导入模块: from cython.importer import Board [as 别名]
# 或者: from cython.importer.Board import at [as 别名]
 def test_normal_move(self):
     board = Board(False)
     board.load_fen("8/8/8/8/8/8/8/4K3 w kQkq - 0 1")
     self.assertEqual(board.at((4, 0)), WK)
     self.assertEqual(True, bool(board.move((4, 0), (4, 1), 5)))
     self.assertEqual(board.at((4, 0)), None)
     self.assertEqual(board.at((4, 1)), WK)
开发者ID:GRUPO-ES2-GJLRT,项目名称:XADREZ_ES2,代码行数:9,代码来源:test_board.py

示例2: test_promotion_move

# 需要导入模块: from cython.importer import Board [as 别名]
# 或者: from cython.importer.Board import at [as 别名]
 def test_promotion_move(self):
     board = Board(False)
     board.load_fen("8/4P3/8/8/8/8/8/8 w kQkq - 0 1")
     self.assertEqual(board.at((4, 6)), WP)
     self.assertEqual(True, bool(board.move((4, 6), (4, 7), 5)))
     # ToDo: verificar. Vai ser sempre rainha?
     self.assertEqual(board.at((4, 7)), WQ)
     self.assertEqual(board.at((4, 6)), None)
开发者ID:GRUPO-ES2-GJLRT,项目名称:XADREZ_ES2,代码行数:10,代码来源:test_board.py

示例3: test_left_en_passant_move

# 需要导入模块: from cython.importer import Board [as 别名]
# 或者: from cython.importer.Board import at [as 别名]
 def test_left_en_passant_move(self):
     board = Board(False)
     board.load_fen("8/3p4/8/4P3/8/8/8/8 b kQkq - 0 1")
     self.assertEqual(True, bool(board.move((3, 6), (3, 4), 5)))
     self.assertEqual(board.at((4, 4)), WP)
     self.assertEqual(board.at((3, 4)), BP)
     self.assertEqual(True, bool(board.move((4, 4), (3, 5), 5)))
     self.assertEqual(board.at((4, 4)), None)
     self.assertEqual(board.at((3, 5)), WP)
     self.assertEqual(board.at((3, 4)), None)
开发者ID:GRUPO-ES2-GJLRT,项目名称:XADREZ_ES2,代码行数:12,代码来源:test_board.py

示例4: test_kingside_castling_move

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

示例5: test_queenside_castling_move

# 需要导入模块: from cython.importer import Board [as 别名]
# 或者: from cython.importer.Board import at [as 别名]
 def test_queenside_castling_move(self):
     board = Board(False)
     board.load_fen("8/8/8/8/8/8/8/R3K3 w kQkq - 0 1")
     self.assertEqual(board.at((4, 0)), WK)
     self.assertEqual(board.at((0, 0)), WR)
     self.assertEqual(True, bool(board.move((4, 0), (2, 0), 5)))
     self.assertEqual(board.at((4, 0)), None)
     self.assertEqual(board.at((0, 0)), None)
     self.assertEqual(board.at((2, 0)), WK)
     self.assertEqual(board.at((3, 0)), WR)
开发者ID:GRUPO-ES2-GJLRT,项目名称:XADREZ_ES2,代码行数:12,代码来源:test_board.py

示例6: test_create_board_new_game_true

# 需要导入模块: from cython.importer import Board [as 别名]
# 或者: from cython.importer.Board import at [as 别名]
    def test_create_board_new_game_true(self):
        board = Board(True)
        # Pawn
        for x in xrange(8):
            self.assertEqual(board.at((x, 6)), BP)
            self.assertEqual(board.at((x, 1)), WP)

        # Rook
        self.assertEqual(board.at((0, 0)), WR)
        self.assertEqual(board.at((7, 0)), WR)
        self.assertEqual(board.at((0, 7)), BR)
        self.assertEqual(board.at((7, 7)), BR)

        # Knight
        self.assertEqual(board.at((1, 0)), WN)
        self.assertEqual(board.at((6, 0)), WN)
        self.assertEqual(board.at((1, 7)), BN)
        self.assertEqual(board.at((6, 7)), BN)

        # Bishop
        self.assertEqual(board.at((2, 0)), WB)
        self.assertEqual(board.at((5, 0)), WB)
        self.assertEqual(board.at((2, 7)), BB)
        self.assertEqual(board.at((5, 7)), BB)

        # Queen
        self.assertEqual(board.at((3, 0)), WQ)
        self.assertEqual(board.at((3, 7)), BQ)

        # King
        self.assertEqual(board.at((4, 0)), WK)
        self.assertEqual(board.at((4, 7)), BK)
开发者ID:GRUPO-ES2-GJLRT,项目名称:XADREZ_ES2,代码行数:34,代码来源:test_board.py

示例7: test_black_pawn_at_e2_with_enemy_at_f1_should_be_promoted_at_f1

# 需要导入模块: from cython.importer import Board [as 别名]
# 或者: from cython.importer.Board import at [as 别名]
 def test_black_pawn_at_e2_with_enemy_at_f1_should_be_promoted_at_f1(self):
     board = Board(False)
     board.load_fen("8/8/8/8/8/8/4p3/5P2 b kQkq f3 0 1")
     pos = (4, 1)
     possible_moves = moves(pos, [(4, 0), (5, 0)])
     self.assertEqual(tuples(board.piece_moves(pos)), possible_moves)
     board.move((4, 1), (5, 0), 5)
     self.assertEqual(board.at((5, 0)), "black queen")
开发者ID:GRUPO-ES2-GJLRT,项目名称:XADREZ_ES2,代码行数:10,代码来源:test_pawn.py

示例8: test_white_pawn_at_e7_with_enemy_at_f8_should_be_promoted_at_f8

# 需要导入模块: from cython.importer import Board [as 别名]
# 或者: from cython.importer.Board import at [as 别名]
 def test_white_pawn_at_e7_with_enemy_at_f8_should_be_promoted_at_f8(self):
     board = Board(False)
     board.load_fen("5p2/4P3/8/8/8/8/8/8 w kQkq f3 0 1")
     pos = (4, 6)
     possible_moves = moves(pos, [(4, 7), (5, 7)])
     self.assertEqual(tuples(board.piece_moves(pos)), possible_moves)
     board.move((4, 6), (5, 7), 5)
     self.assertEqual(board.at((5, 7)), "white queen")
开发者ID:GRUPO-ES2-GJLRT,项目名称:XADREZ_ES2,代码行数:10,代码来源:test_pawn.py

示例9: test_create_board_new_game_false

# 需要导入模块: from cython.importer import Board [as 别名]
# 或者: from cython.importer.Board import at [as 别名]
 def test_create_board_new_game_false(self):
     board = Board(False)
     for x in xrange(8):
         for y in xrange(8):
             self.assertEqual(board.at((x, y)), None)
开发者ID:GRUPO-ES2-GJLRT,项目名称:XADREZ_ES2,代码行数:7,代码来源:test_board.py

示例10: test_checkmate

# 需要导入模块: from cython.importer import Board [as 别名]
# 或者: from cython.importer.Board import at [as 别名]
 def test_checkmate(self):
     board = Board(False)
     board.load_fen("4k3/8/8/5R2/8/8/8/3R1R2 w kQkq - 0 1")
     self.assertEqual(True, bool(board.move((5, 4), (4, 4), 5)))
     self.assertEqual(board.at((5, 4)), None)
     self.assertEqual(board.at((4, 4)), WR)
开发者ID:GRUPO-ES2-GJLRT,项目名称:XADREZ_ES2,代码行数:8,代码来源:test_board.py

示例11: test_invalid_keep_check

# 需要导入模块: from cython.importer import Board [as 别名]
# 或者: from cython.importer.Board import at [as 别名]
 def test_invalid_keep_check(self):
     board = Board(False)
     board.load_fen("8/4P3/8/8/8/8/4P3/r3Kr2 w kQkq - 0 1")
     self.assertEqual(False, board.move((4, 0), (5, 0), 5))
     self.assertEqual(board.at((4, 0)), WK)
     self.assertEqual(board.at((5, 0)), BR)
开发者ID:GRUPO-ES2-GJLRT,项目名称:XADREZ_ES2,代码行数:8,代码来源:test_board.py

示例12: test_get_from_invalid_position_returns_none

# 需要导入模块: from cython.importer import Board [as 别名]
# 或者: from cython.importer.Board import at [as 别名]
 def test_get_from_invalid_position_returns_none(self):
     board = Board(False)
     self.assertEqual(board.at((-4, 4)), None)
开发者ID:GRUPO-ES2-GJLRT,项目名称:XADREZ_ES2,代码行数:5,代码来源:test_board.py

示例13: test_get_from_valid_position_with_piece_returns_piece

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

示例14: test_get_from_valid_position_without_piece_returns_none

# 需要导入模块: from cython.importer import Board [as 别名]
# 或者: from cython.importer.Board import at [as 别名]
 def test_get_from_valid_position_without_piece_returns_none(self):
     board = Board(False)
     self.assertEqual(board.at((4, 4)), None)
开发者ID:GRUPO-ES2-GJLRT,项目名称:XADREZ_ES2,代码行数:5,代码来源:test_board.py


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