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


Python Board.move方法代码示例

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


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

示例1: 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 move [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

示例2: 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 move [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

示例3: test_left_en_passant_move

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

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

示例5: test_promotion_move

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

示例6: test_kingside_castling_move

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

示例7: test_queenside_castling_move

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

示例8: Chess

# 需要导入模块: from cython.importer import Board [as 别名]
# 或者: from cython.importer.Board import move [as 别名]
class Chess(Scene, ChessInterface):

    def __init__(self, game, level_white, level_black, *args, **kwargs):
        super(Chess, self).__init__(game, *args, **kwargs)
        self.finished = False
        self.game = game
        self.white_minutes = lambda: "20:00"
        self.black_minutes = lambda: "20:00"
        self.define_clicks()
        self.create_interface()

        self.level_white = level_white
        self.level_black = level_black

        self.new_game()

    @property
    def current_player(self):
        return self.players[self.board.color()]

    @property
    def other_player(self):
        return self.players[next(self.board.color())]

    @property
    def human_player(self):
        return isinstance(self.current_player, InputPlayer)

    def define_clicks(self):
        def draw_click(it):
            if self.human_player:
                self.other_player.confirm_draw()

        def resign_click(it):
            if self.human_player:
                self.current_player.lose()

        def motion(it, collides):
            if not self.human_player or not collides:
                it.color = self.button_color
            else:
                it.color = self.button_hover
                self.do_jit_draw()
            it.redraw()

        def motion_group(it, collides):
            if collides:
                self.do_jit_draw()

        self.draw_click = draw_click
        self.resign_click = resign_click
        self.motion = motion
        self.motion_group = motion_group

    def new_game(self):
        self.free_events()
        self.config = self.load_stored_config()
        self.fifty_move = self.config['fifty_move']
        self.jit_draw = self.config['jit_draw']
        self.ai_timeout = self.config['timeout']
        self.board = Board(True)
        # Marked squares
        self.selected = None
        self.fail = None
        self.check = None

        # Game states and countdown for check message
        self.countdown = 0
        self.denied_countdown = 0
        self.draw_delta = 0
        self.state = None

        self.initialize_players()
        self.game.scene = self
        self.do_jit_draw()

    def initialize_players(self):
        new_timer = lambda: TIMER_CLASS[self.config['timer']](self.config)
        white = create_player(WHITE, new_timer(), self, self.level_white)
        black = create_player(BLACK, new_timer(), self, self.level_black)
        self.players = {
            WHITE: white,
            BLACK: black,
        }
        self.white_minutes = lambda: white.timer.minutes_to_text()
        self.black_minutes = lambda: black.timer.minutes_to_text()
        self.thread_events = [white.timer.event, black.timer.event]
        self.current_player.start_turn()

    def draw(self, delta_time):
        self.draw_delta += delta_time
        if (0 < self.countdown < delta_time or
                0 < self.denied_countdown < delta_time or
                self.draw_delta >= MAX_DRAW_DELTA):
            self.should_draw = True
        self.draw_delta %= MAX_DRAW_DELTA

        self.countdown = max(self.countdown - delta_time, 0)
        self.denied_countdown = max(self.denied_countdown - delta_time, 0)
        if self.should_draw:
#.........这里部分代码省略.........
开发者ID:GRUPO-ES2-GJLRT,项目名称:XADREZ_ES2,代码行数:103,代码来源:chess.py

示例9: test_checkmate

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

示例10: test_invalid_keep_check

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

示例11: test_invalid_color

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

示例12: test_invalid_equal_position

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

示例13: test_no_piece_on_original_position

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

示例14: test_invalid_original_position

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


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