def test_mock_play_2(self): g = sorry.game() s1 = sorry.strategy(g) s2 = sorry.strategy(g) p1 = sorry.player("Bob", "YELLOW", s1) p2 = sorry.player("Joe", "GREEN", s2) s1.set_player(p1) s2.set_player(p2) card = sorry.card2() for i in xrange(28): s1.apply(card) s2.apply(card) self.assertEqual(p1.pawns[0].position, 166) self.assertEqual(p2.pawns[0].position, 181)
def test_mock_play_whole_deck(self): random.seed(0) s2 = sorry.strategy(self.g) p2 = sorry.player("Joe", "GREEN", s2) s2.set_player(p2) self.g._players = [self.p, p2] deck = [ sorry.card1(), sorry.card2(), sorry.card3(), sorry.card4(), sorry.card5(), sorry.card7(), sorry.card8(), sorry.card10(), sorry.card11(), sorry.cardsorry(), sorry.card12() ] for i in xrange(161): card1 = deck[random.randint(0, len(deck) - 1)] card2 = deck[random.randint(0, len(deck) - 1)] s2.apply(card1) print card1 print p2.positions() self.s.apply(card2) print card2 print self.p.positions() self.assertTrue(self.p.is_win()) self.assertTrue(p2.is_win())
def test_mock_play_1(self): g = sorry.game() s1 = sorry.strategy(g) s2 = sorry.strategy(g) p1 = sorry.player("Bob", "YELLOW", s1) p2 = sorry.player("Joe", "GREEN", s2) s1.set_player(p1) s2.set_player(p2) card = sorry.card1() for i in xrange(160): s1.apply(card) s2.apply(card) self.assertTrue(p1.is_win()) self.assertTrue(p2.is_win())
def test_move_sorry_strategy_1(self): card = sorry.cardsorry() s2 = sorry.strategy(self.g) p2 = sorry.player("Joe", "GREEN", s2) s2.set_player(p2) s2._player._pawns[0].position = 32 self.g._players = [self.p, p2] self.s.apply(card) self.assertEqual(self.s._player.pawns[0].position, 32) self.assertEqual(s2._player.pawns[0].position, -1)
def test_mock_play_7(self): g = sorry.game() s1 = sorry.strategy(g) s2 = sorry.strategy(g) p1 = sorry.player("Bob", "YELLOW", s1) p2 = sorry.player("Joe", "GREEN", s2) s1.set_player(p1) s2.set_player(p2) card = sorry.card7() card_out = sorry.card1() for i in xrange(11): if not self.avaliable_pawns(p1.pawns): s1.apply(card_out) s2.apply(card_out) continue s1.apply(card) s2.apply(card) self.assertEqual(p1.pawns[0].position, 163) self.assertEqual(p2.pawns[0].position, 178)
def test_mock_play_5(self): g = sorry.game() s1 = sorry.strategy(g) s2 = sorry.strategy(g) p1 = sorry.player("Bob", "YELLOW", s1) p2 = sorry.player("Joe", "GREEN", s2) s1.set_player(p1) s2.set_player(p2) card = sorry.card5() card_out = sorry.card1() for i in xrange(56): if not self.avaliable_pawns(p1.pawns): s1.apply(card_out) s2.apply(card_out) continue s1.apply(card) s2.apply(card) self.assertTrue(p1.is_win()) self.assertTrue(p2.is_win())
def setUp(self): self.g = sorry.game() self.s = sorry.strategy(self.g) self.p = sorry.player("Bob", "YELLOW", self.s) self.s.set_player(self.p)