Selecting a number from an array, only allowing certain numbers to follow

  • Is your goal to do 10-print style population of the grid, L-R, T-B? So you check each tile before you place it down? Or do you want to be able to grow, flood-fill, or change the tile grid in random directions?
  • Is it possible for you to create an impossible tile? That is, are there any combinations A B such that for:
A
B C

…there is no solution C?

Your problem space is somewhat related to Conway’s Game of Life implementations, of which there are many in Processing. Those are more complicated, but some of the considerations are the same.