本文整理汇总了Python中position.Position.copy方法的典型用法代码示例。如果您正苦于以下问题:Python Position.copy方法的具体用法?Python Position.copy怎么用?Python Position.copy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类position.Position
的用法示例。
在下文中一共展示了Position.copy方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_pawn_captures
# 需要导入模块: from position import Position [as 别名]
# 或者: from position.Position import copy [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"))
示例2: TestPosition
# 需要导入模块: from position import Position [as 别名]
# 或者: from position.Position import copy [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())