mardi 23 octobre 2018

Generating a Random Variable that does not overlap with previous ones while placing components

I'm randomly placing components on a grid using random variables in Python, with the following line of code repeated for the no of components to be placed:

[random.randint(0,32), random.randint(0,27), random.randint(0,3), 1]

And, I also have parts sizes for each of the parts in an array like this:

 partSizes = [[[10, 10], [4, 2], [4, 2]]]

So, when I'm randomly placing parts on my grid, some of them get overlapped which I need to avoid by skipping the portion of grid that's occupied with the previously placed parts. I'm very new to Python so I'm having a hard time figuring this out. Any help will be much appreciated. Regards




Aucun commentaire:

Enregistrer un commentaire