I have to generate a random connected binary 2D grid, for example:
0 1 1 0
1 0 0 1
0 1 0 1
From a given point labeled as 1, I have to able to reach any other point labeled as 1. 0's are the walls and it's 8-way. No point 1 disconnected ('alone') is allowed, neither a set of points 1.
How can I generate such matrix? I have tried something in PHP, but couldn't find the right and guaranteed solution.
Aucun commentaire:
Enregistrer un commentaire