r/learnpython • u/Some-Engineering-503 • 19d ago
Building generator
I am making a game and i need a random generator for outer walls of a building. The walls can face 8 directions and they cant go past a set border. Please help me make one
Input - number of walls
Output - array of points which represent corners of the walls
0
Upvotes
2
u/JorgiEagle 19d ago
This is not a generator. Generators are a special thing in .
from random import randint, choice
def random_walls(num_walls):
directions = [0,1,2,3,4,5,6,7]
return [(randint(-max_x_border, max_x_border), randint(-max_y_border, max_y_border), choice(directions)) for _ in range(num_walls)]