I am creating a 2d tile game, and am wondering what the best way to generate a cluster of a certain tile type within. For example, say I have a 2d array that is my map. Grass is represented by 0.
{{0, 0, 0, 0, 0, 0}
{0, 0, 0, 0, 0, 0}
{0, 0, 0, 0, 0, 0}
{0, 0, 0, 0, 0, 0}
{0, 0, 0, 0, 0, 0}
{0, 0, 0, 0, 0, 0}}
Now, what I want to do is randomly create a cluster of trees (represented by 1) in my array. I want it to look something like this:
{{0, 0, 0, 0, 0, 0}
{0, 0, 0, 0, 0, 0}
{0, 1, 1, 1, 0, 0}
{0, 1, 1, 1, 1, 0}
{0, 0, 1, 1, 1, 0}
{0, 0, 1, 1, 0, 0}}
What would be the best way to do this?