0
$\begingroup$

I have a map that is 300x300 units. I have to place squares of 20x20 units inside that map from outside to inside. There are 3 different types of square, the space available inside the map needs to be split equally to them, so from outside to inside the squares type 1 start to fill in the map until their limit is reached, then the square types 2 and 3 do the same until the map is fully filled with the squares.

Poor drawing example: enter image description here

I apologize if I wasn't clear enough.

$\endgroup$
  • $\begingroup$ What does it mean by "the space available inside the map needs to be split equally to them"? As I counted, there are 28 white squares, 20 blue squares and 12 gree squares. I am not sure if 28, 20 and 12 are equal. $\endgroup$ – John L. Dec 23 '18 at 17:23
  • $\begingroup$ I Apologize, the drawing is just a representation of the distribution and does not reflect the actual amount of squares that can fit inside the map. I want the algorithm to also calculate how many of them can fit in there since the map's size can variate. So with that information the available spaces are split to the 3 different types of squares. $\endgroup$ – user3306761 Dec 23 '18 at 19:05
  • $\begingroup$ (300/20) * (300/20) = 15 * 15 = 225 pieces. 225/3=75. Do you mean you want to put 75 square of type one on the outside, then 75 squares of type in the center and 75 squares in between? $\endgroup$ – John L. Dec 23 '18 at 19:34
  • $\begingroup$ Exactly. But it should be placed from the outside to the inside like I mentioned, so I need to run the iteration and place every frame at the correct x and y position. If you're wondering and if it's helpful I'm using Unity+C# $\endgroup$ – user3306761 Dec 23 '18 at 19:52
  • $\begingroup$ "it should be placed from the outside to the inside like I mentioned." However, the way you have drawn, where outermost squares of each type form a rectangle, is not possible. Can you clarify exactly how they are supposed to be placed? $\endgroup$ – John L. Dec 24 '18 at 5:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.