Assume you have a n x m matrix. In this matrix, you will be randomly positioning FOUR different objects say a, b, c, d. There will be many of each.
Now what is the best algorithm so that when they are randomly placed, their positions don't clash?
My approach would be to:
- Randomly place them
- Check through all the object's position, and if they clash, keep on moving until an empty space is found?
I am just wondering if there is any other efficient solution.