Depending on the square of the given position in the game, choose a different color so that the remaining more squares are the same color. When all the squares are the same color, you have finished the game.