import math
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.patches as patches
import random


"""
Helper Functions
"""
def create_random_starts_and_goals(env, num_agents):
    """
    Given some map file, create a set of starts and goals for the specified 
    number of agents. This function will create a file folowing the agent file format.
    """

    starts = []
    goals = []

    for i in range(num_agents):
        # generate a random start
        x = random.uniform(env.boundary[0][0], env.boundary[0][1])
        y = random.uniform(env.boundary[1][0], env.boundary[1][1])
    
        while [x,y] in starts:
            x = random.uniform(env.boundary[0][0], env.boundary[0][1])
            y = random.uniform(env.boundary[1][0], env.boundary[1][1])

        starts.append([x,y,0])

        # generate a random goal
        x = random.uniform(env.boundary[0][0], env.boundary[0][1])
        y = random.uniform(env.boundary[1][0], env.boundary[1][1])
    
        while [x,y] in goals:
            x = random.uniform(env.boundary[0][0], env.boundary[0][1])
            y = random.uniform(env.boundary[1][0], env.boundary[1][1])

        goals.append([x,y])

    return starts,goals

def read_agents_from_file(fname):
    pass

def generate_random_agents(num_agents):
    pass

def read_environment_from_file(fname):
    pass