class TestSorting(unittest.TestCase): def setUp(self): self.names = ['Alice', 'Bob', 'Carl'] self.players = [Player(x) for x in self.names] self.board = Board(self.players) def test_high_unique(self): self.pile = [] self.pile.append(self.players[0].select_card(15)) self.pile.append(self.players[1].select_card(15)) self.pile.append(self.players[2].select_card(13)) debug('Highest unique card: %s' % self.board.find_highest(self.pile)) self.assertEqual(self.board.find_highest(self.pile).owner.name, 'Carl') def test_low_unique(self): self.pile = [] self.pile.append(self.players[0].select_card(1)) self.pile.append(self.players[1].select_card(1)) self.pile.append(self.players[2].select_card(3)) debug('Lowest unique card: %s' % self.board.find_lowest(self.pile)) self.assertEqual(self.board.find_lowest(self.pile).owner.name, 'Carl') def test_tied(self): """ Test for a tie when all cards are the same """ self.pile = [] self.pile.append(self.players[0].select_card(15)) self.pile.append(self.players[1].select_card(15)) self.pile.append(self.players[2].select_card(15)) self.assertEqual(self.board.find_highest(self.pile), None)
class TestPlay(unittest.TestCase): def setUp(self): self.names = ['Alice', 'Bob', 'Carl'] self.players = [RandBot(x) for x in self.names] self.board = Board(self.players) def test_playthrough(self): self.board.run() print self.board.games
def robots(): bots = [RandBot('Alice'), PatternBot('Bob'), RandBot('Carl'), KmgOneBot('Ken')] board = Board(bots, 30) board.run() print board.scoreboard
def humans(): PLAYERNAMES = ['Kevin', 'Bob', 'Alice'] humans = [Player(x) for x in PLAYERNAMES] board = Board(humans) board.run() print board.scoreboard
def human_v_robot(): players = [Player('Eric'), RandBot('RandBot')] board = Board(players) board.run() print board.scoreboard
def setUp(self): self.names = ['Alice', 'Bob', 'Carl'] self.players = [RandBot(x) for x in self.names] self.board = Board(self.players)