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


Python Position.make_move方法代码示例

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


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

示例1: TestPosition

# 需要导入模块: from position import Position [as 别名]
# 或者: from position.Position import make_move [as 别名]
class TestPosition(unittest.TestCase):
    
    def setUp(self):
        self.pos = Position()
        self.pos_dup = Position()
        self.pos_other = Position()
        self.pos_other.make_move(Move.from_uci('e2e4'))

    def test___delitem__(self):
        del self.pos['a1']
        self.assertIs(None, self.pos['a1'])

    def test___eq__(self):
        self.assertEqual(True, self.pos == self.pos_dup)
        self.assertEqual(False, self.pos == self.pos_other)

    def test___getitem__(self):
        self.assertEqual(True, self.pos['e1'] == 'K')

    def test___hash__(self):
        self.assertEqual(True, hash(self.pos) == hash(self.pos_dup))
        self.assertEqual(False, hash(self.pos) != hash(self.pos_other))

    def test___ne__(self):
        self.assertEqual(False, self.pos != self.pos_dup)
        self.assertEqual(True, self.pos != self.pos_other)

    def test___repr__(self):
        self.assertEqual("Position('%s')" % Fen(), repr(self.pos))

    def test___setitem__(self):
        self.pos['a1'] = 'K'
        self.assertEqual('K', self.pos['a1'])

    def test___str__(self):
        self.assertEqual(str(Fen()), str(self.pos))
        self.assertEqual(False, str(self.pos) == str(self.pos_other))

    def test_copy(self):
        copy = self.pos.copy()
        self.assertEqual(copy, self.pos)

    def test_is_check(self):
        self.assertEqual(False, self.pos.is_check())

    def test_is_checkmate(self):
        self.assertEqual(False, self.pos.is_checkmate())

    def test_is_game_over(self):
        self.assertEqual(False, self.pos.is_game_over())

    def test_is_insufficient_material(self):
        self.assertEqual(False, self.pos.is_insufficient_material())

    def test_is_king_attacked(self):
        self.assertEqual(False, self.pos.is_king_attacked(WHITE))

    def test_is_stalemate(self):
        self.assertEqual(False, self.pos.is_stalemate())
开发者ID:arthurfait,项目名称:kivy-chess,代码行数:61,代码来源:test_position.py

示例2: test_single_step_pawn_move

# 需要导入模块: from position import Position [as 别名]
# 或者: from position.Position import make_move [as 别名]
 def test_single_step_pawn_move(self):
     """Tests that single step pawn moves are possible."""
     pos = Position()
     a3 = Move.from_uci('a2a3')
     self.assertTrue(a3 in pos.get_pseudo_legal_moves())
     self.assertTrue(a3 in pos.get_legal_moves())
     pos.get_move_info(a3)
     pos.make_move(a3)
开发者ID:arthurfait,项目名称:kivy-chess,代码行数:10,代码来源:old_test_position.py

示例3: test_pawn_captures

# 需要导入模块: from position import Position [as 别名]
# 或者: from position.Position import make_move [as 别名]
    def test_pawn_captures(self):
        """Tests pawn captures in the kings gambit."""
        pos = Position()
        pos.make_move(pos.get_move_from_san("e4"))
        pos.make_move(pos.get_move_from_san("e5"))
        pos.make_move(pos.get_move_from_san("f4"))

        accepted = pos.copy()
        self.assertTrue(Move.from_uci("e5f4") in accepted.get_pseudo_legal_moves())
        self.assertTrue(Move.from_uci("e5f4") in accepted.get_legal_moves())
        accepted.make_move(accepted.get_move_from_san("exf4"))

        wierd_declined = pos.copy()
        wierd_declined.make_move(wierd_declined.get_move_from_san("d5"))
        wierd_declined.make_move(wierd_declined.get_move_from_san("exd5"))
开发者ID:arthurfait,项目名称:kivy-chess,代码行数:17,代码来源:old_test_position.py

示例4: test_scholars_mate

# 需要导入模块: from position import Position [as 别名]
# 或者: from position.Position import make_move [as 别名]
    def test_scholars_mate(self):
        """Tests the scholars mate."""
        pos = Position()
        self.assertTrue(pos.get_castling_right("q"))

        e4 = Move.from_uci('e2e4')
        self.assertTrue(e4 in pos.get_legal_moves())
        pos.make_move(e4)
        self.assertTrue(pos.get_castling_right("q"))

        e5 = Move.from_uci('e7e5')
        self.assertTrue(e5 in pos.get_legal_moves())
        self.assertFalse(e4 in pos.get_legal_moves())
        pos.make_move(e5)
        self.assertTrue(pos.get_castling_right("q"))

        Qf3 = Move.from_uci('d1f3')
        self.assertTrue(Qf3 in pos.get_legal_moves())
        pos.make_move(Qf3)
        self.assertTrue(pos.get_castling_right("q"))

        Nc6 = Move.from_uci('b8c6')
        self.assertTrue(Nc6 in pos.get_legal_moves())
        pos.make_move(Nc6)
        self.assertTrue(pos.get_castling_right("q"))

        Bc4 = Move.from_uci('f1c4')
        self.assertTrue(Bc4 in pos.get_legal_moves())
        pos.make_move(Bc4)
        self.assertTrue(pos.get_castling_right("q"))

        Rb8 = Move.from_uci('a8b8')
        self.assertTrue(Rb8 in pos.get_legal_moves())
        pos.make_move(Rb8)
        self.assertFalse(pos.get_castling_right("q"))

        self.assertFalse(pos.is_check())
        self.assertFalse(pos.is_checkmate())
        self.assertFalse(pos.is_game_over())
        self.assertFalse(pos.is_stalemate())

        Qf7_mate = Move.from_uci('f3f7')
        self.assertTrue(Qf7_mate in pos.get_legal_moves())
        pos.make_move(Qf7_mate)

        self.assertTrue(pos.is_check())
        self.assertTrue(pos.is_checkmate())
        self.assertTrue(pos.is_game_over())
        self.assertFalse(pos.is_stalemate())

        self.assertEqual(pos.fen, "1rbqkbnr/pppp1Qpp/2n5/4p3/2B1P3/8/PPPP1PPP/RNB1K1NR b KQk - 0 4")
开发者ID:arthurfait,项目名称:kivy-chess,代码行数:53,代码来源:old_test_position.py

示例5: test_san_moves

# 需要导入模块: from position import Position [as 别名]
# 或者: from position.Position import make_move [as 别名]
    def test_san_moves(self):
        """Tests making moves from SANs."""
        pos = Position()

        pos.make_move(pos.get_move_from_san('Nc3'))
        pos.make_move(pos.get_move_from_san('c5'))

        pos.make_move(pos.get_move_from_san('e4'))
        pos.make_move(pos.get_move_from_san('g6'))

        pos.make_move(pos.get_move_from_san('Nge2'))
        pos.make_move(pos.get_move_from_san('Bg7'))

        pos.make_move(pos.get_move_from_san('d3'))
        pos.make_move(pos.get_move_from_san('Bxc3'))

        pos.make_move(pos.get_move_from_san('bxc3'))

        self.assertEqual(pos.fen, 'rnbqk1nr/pp1ppp1p/6p1/2p5/4P3/2PP4/P1P1NPPP/R1BQKB1R b KQkq - 0 5')
开发者ID:arthurfait,项目名称:kivy-chess,代码行数:21,代码来源:old_test_position.py


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