def init_game():
    '''
    Creates and instance of the game for 2 players
    and runs until there is a winner
    '''
    game_state=connectfour.new_game_state()
    connectfourfunctions.print_board_game(game_state.board)


    winner = ' '
    
    while True:
        try:
            player=(input(game_state.turn + ":Drop and a col number or Pop and a col number: "))
            command,col=player.split()
            col=int(col)
            game_state=connectfourfunctions.give_turn(game_state,command,col)            
        except:
            pass
        winner=connectfour.winning_player(game_state)
        connectfourfunctions.print_board_game(game_state.board)
        
        if (winner != ' '):
            print(winner+" Won")
            break
def _run_user_interface() -> None:
    '''
    Runs the console-mode user interface from start to finish.
    Depending on if there is a winner or not, the end state game
    board will or will not be printed
    '''
    winner = ' '
    
    host=str((input("Enter Host: ")))
    port=int((input("Enter Port: ")))   

    try:
       connection = connectfourserver.connect(host,port)   
       username = _ask_for_username()
       connectfourserver.hello(connection, username)
       connectfourfunctions.print_board_game(game_state.board)

       while _handle_command(connection):
           _handle_ai_command(connection)
           if connectfourserver._expect_line(connection, 'READY') == False:
               break
           connectfourfunctions.print_board_game(game_state.board)
    except:
        print("Error when Connecting")
        connection=None

    finally:        
        winner=connectfour.winning_player(game_state)
        if (winner != ' '):
            connectfourfunctions.print_board_game(game_state.board)
        if(connection!=None):
            connectfourserver.close(connection)