import json


def get_average_profit(file_name, bot_name, initial_stack):
    """
    Given the name for a game results JSON file, the name of our bot, and 
    the initial stack the bot started out with in each game, return the average
    profit of that bot.
    """
    gameplay_data_file = open(file_name, 'r')
    game_results = gameplay_data_file.read()
    gameplay_data_file.close()


    results = game_results.split('}')
    results = results[: len(results) - 1]
    result_dicts = []
    for result in results:
        result += '}'
        result_dicts.append(json.loads(result))
    final_stacks = 0
    num_results = len(result_dicts)
    for dict in result_dicts:
        final_stacks += dict[bot_name]

    return (final_stacks / num_results) - initial_stack