Negative x and y range

Issue

My problem is that the generated_map is not utilizing full negative range for x and y

def generate_map(x_range, y_range, locations):

    generated_map = []

    for x in range(locations):
        generated_map.append([random.randint(x_range, y_range), random.randint(x_range, y_range)])
        
    

    return generated_map

generated_map = generate_map(-300,300,35)

Solution

So the issue with this was the for loop.

for x in range(locations):
        x_value = random.randint(-x_range, x_range)
        y_value = random.randint(-y_range, y_range)

        generated_map.append([x_value, y_value])

Answered By – EngineerHus123

Answer Checked By – Senaida (AngularFixing Volunteer)

Leave a Reply

Your email address will not be published.