def play_game(self): '''Main function to play the game. ''' self.game_status = 'In-Progress' game = TicTacToe() player1 = self.create_player(player_id=1) player2 = self.create_player(player_id=2) self.game_positions = game.generate_all_positions() self.available_choices = list(self.game_positions.keys()) round_count = 0 while len(self.available_choices) > 1: round_count += 1 print('\n') print(f'Round {round_count}:') print('---------') player1 = self.record_player_move(player1) player2 = self.record_player_move(player2) for player in [player1, player2]: if game.check_player_game_status(player): player_name = player['Name'] self.game_status = f'Player {player_name} has Won' break if self.game_status != 'In-Progress': game.display_current_positions(player1, player2) print('Game status:', self.game_status) return if self.game_status == 'In-Progress' and len( self.available_choices) >= 3: game.display_current_positions(player1, player2) print('Game status:', self.game_status) game.display_current_positions(player1, player2) self.game_status = 'Draw' print('Game status:', self.game_status) return