I haven't really researched that. But I have a simple idea.
First, we can create a "State" object which stores the full board. Next, one can write an algorithm to generate a "hash" of the current state. This can be based on any logic. Eg hashcode of
string containing all cells with row, col values separated by a delimiter.
Now, all we have to do is to generate a list of states and advance the game further. For every new state, a search can be made on all previous states. Here's where our hash comes in handy, to filter out all states matching our hash to make our search faster. They may or may not be the same since collisions are expected. The better the hash algorithm, the faster our search gets.
My logic is a "brute force" one
there could be better ways.