Suppose I have the following matrix:
[[1, 1, 1, 0, 0, 0]
[1, 1, 1, 0, 0, 0]
[1, 1, 1, 0, 0, 0]]
No tiles can hold other values besides 0 or 1. In this situation, 0 represents walkable space, while 1 represents a wall. How can I output the minimum amount of walls and open spaces as boxes? The previous matrix would produce 2 objects: A box with a value of wall from 0 to 2 on x and y, and a box with a value of platform from 2 to 4 on x and y axis. Suppose we have something like this, though:
[[0, 0, 1, 1, 0, 0]
[0, 1, 1, 1, 0, 0]
[0, 1, 1, 1, 0, 0]]
In this case, box with a value of platform is generated at 0 on the x axis from 0 to 2 on the y axis. Another box with a value of platform is generated at 1, 0, it being only 1 tile wide. A final box related to the platforms is generated from 4 to 5 and 0 to 2 on the x and y-axis. The walls are a little more ambiguous because there are two possible configurations in which we could have the least amount of walls. We could spawn a polygon from 1 to 3 on the x and 1 to 2 on the y and another polygon from 2 to 3 on the x axis and 0 on the y axis. We can also invert these. Another valid choice would be to have a wall from 2 to 3 on the x and 0 to 2 on the y and another wall at 1 on the x-axis going from 1 to 2 on the y-axis. These are both equal because when calculating their area the resulting two integers equal. As such, either output is acceptable.
Trouble is, I don't know what exactly to look up to even begin drawing up a rough draft of how this is going to look. I've stumbled on Tesslazation (I think that's how you spell it) but that is focused on rendering and more often produces small triangles rather than large rectangles / squares. Is this another design issue -- no perfect formula, or am I just typing wrong words into Google?