def main(raw_input=raw_input): player_collection = get_participating_players() tournament = Tournament(player_collection) wants_another_game = "y" while wants_another_game == "y": winner = tournament.play_game() try: winning_marker = winner.marker print "The winner is player", winning_marker except: print "The game is a tie! Everybody wins!" wants_another_game = raw_input("Another game? (y for yes):") print_results(player_collection)
class TournamentTest(unittest.TestCase): def setUp(self): self.player1 = ComputerPlayer('X') self.player2 = ComputerPlayer('O') self.players = (self.player1, self.player2) self.tournament = Tournament(self.players) def testPlayedGameEnds(self): winner = None while not winner: winner = self.tournament.play_game() self.assertEquals(1, winner.games_won) def testGetWinnerOrNone(self): self.assertIs(self.tournament._get_winner_or_none(None), None) self.assertIs(self.tournament._get_winner_or_none('O'), self.player2)
def setUp(self): self.player1 = ComputerPlayer('X') self.player2 = ComputerPlayer('O') self.players = (self.player1, self.player2) self.tournament = Tournament(self.players)