I am looking for an algorithm that does as follows:
Given a 2D grid of X,Y and a number of tiles T, places a tile in each cell of the grid such that the surrounding tiles are not the same.
This should also ideally be capable of providing a random seed to randomize the output.
I understand that for not all values of X, Y and T this is possible, but is there an existing algorithm that will do what I'm looking for? I'm currently using a naive hand-rolled implementation that doesn't always provide the best results.
Is something like a constraint solver what I need?