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


Python Board.load_fen方法代码示例

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


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

示例1: test_queen_at_h8_and_can_move_to_H_and_8_and_diagonal_a1_to_h8

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

示例2: test_normal_move

# 需要导入模块: from cython.importer import Board [as 别名]
# 或者: from cython.importer.Board import load_fen [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

示例3: test_queen_at_a1_and_can_move_to_A_and_1_and_diagonal_a1_to_h8

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

示例4: test_knight_can_move_to_protect_the_king2

# 需要导入模块: from cython.importer import Board [as 别名]
# 或者: from cython.importer.Board import load_fen [as 别名]
 def test_knight_can_move_to_protect_the_king2(self):
     board = Board(False)
     board.load_fen("8/8/8/4N3/2q1K3/8/8/8 w kQkq - 0 1")
     pos = (4, 4)
     possible_moves = moves(pos, [
         (2, 3)
     ])
     self.assertEqual(tuples(board.piece_moves(pos)), possible_moves)
开发者ID:GRUPO-ES2-GJLRT,项目名称:XADREZ_ES2,代码行数:10,代码来源:test_knight.py

示例5: test_knight_can_move_if_it_doesnt_protect_the_king

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

示例6: test_knight_at_a1_and_ally_at_c2_can_move_to_1_position

# 需要导入模块: from cython.importer import Board [as 别名]
# 或者: from cython.importer.Board import load_fen [as 别名]
 def test_knight_at_a1_and_ally_at_c2_can_move_to_1_position(self):
     board = Board(False)
     board.load_fen("8/8/8/8/8/8/2N5/N7 w kQkq - 0 1")
     pos = (0, 0)
     possible_moves = moves(pos, [
         (1, 2)
     ])
     self.assertEqual(tuples(board.piece_moves(pos)), possible_moves)
开发者ID:GRUPO-ES2-GJLRT,项目名称:XADREZ_ES2,代码行数:10,代码来源:test_knight.py

示例7: test_knight_at_a1_can_move_to_2_positions

# 需要导入模块: from cython.importer import Board [as 别名]
# 或者: from cython.importer.Board import load_fen [as 别名]
 def test_knight_at_a1_can_move_to_2_positions(self):
     board = Board(False)
     board.load_fen("8/8/8/8/8/8/8/N7 w kQkq - 0 1")
     pos = (0, 0)
     possible_moves = moves(pos, [
         (2, 1), (1, 2)
     ])
     self.assertEqual(tuples(board.piece_moves(pos)), possible_moves)
开发者ID:GRUPO-ES2-GJLRT,项目名称:XADREZ_ES2,代码行数:10,代码来源:test_knight.py

示例8: test_knight_at_e5_can_move_to_8_positions

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

示例9: test_rook_at_a1_with_ally_in_b1_can_move_to_all_A

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

示例10: 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 load_fen [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

示例11: 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 load_fen [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

示例12: test_rook_at_h8_with_allies_in_f8_and_h6_can_move_to_g8_and_h7

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

示例13: test_B_at_a1_and_an_b_at_e5_can_move_to_b2_and_c3_and_d4_and_e5

# 需要导入模块: from cython.importer import Board [as 别名]
# 或者: from cython.importer.Board import load_fen [as 别名]
 def test_B_at_a1_and_an_b_at_e5_can_move_to_b2_and_c3_and_d4_and_e5(self):
     board = Board(False)
     board.load_fen("8/8/8/4b3/8/8/8/B7 w kQkq - 0 1")
     pos = (0, 0)
     possible_moves = moves(pos, [
         (1, 1), (2, 2), (3, 3), (4, 4)
     ])
     self.assertEqual(tuples(board.piece_moves(pos)), possible_moves)
开发者ID:GRUPO-ES2-GJLRT,项目名称:XADREZ_ES2,代码行数:10,代码来源:test_bishop.py

示例14: test_promotion_move

# 需要导入模块: from cython.importer import Board [as 别名]
# 或者: from cython.importer.Board import load_fen [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

示例15: test_rook_at_a1_with_ally_in_a2_can_move_to_all_1

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


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