[Math] Number of moves to solve a flood-it/sock-dye game

combinatorial-game-theorycombinatoricsgame theory

[ Question based on the sock dye game ]

[ Update: It appears that this game is better known as "Flood it" and is NP-hard. Also, "the number of moves required to flood the whole board is $\Omega(n)$ with high probability." ]

Question: How many color changes (= moves) are needed to complete a $n\times n$ game of $c$ colors? That is:

  1. What is the expected number of minimum moves needed?
  2. What is the maximum number of moves needed?

Is there a strategy that always solves the game with minimum moves?*

Description of the game

Given an $n\times m$ grid where each node is painted with a random color between $c$ possible colors, we define a cluster ("our" cluster) of neighboring nodes that contains only nodes of the same color and must include the upper left node.

Grid of the game

We can change the color of our cluster at will, thus extending it. The goal is to expand our cluster to all the grid.

* Where is the proper place to ask this?

Best Answer

Well, it's easy to say something about the case $c=2$. There is no strategy, since all you can do is alternate between the two colors. Since there is a path of length $2n-2$ (counting the edges) between any two points, no game can take more than $2n-2$ moves. It's easy to construct a game that takes $2n-2$ moves; just use a checkerboard coloring.

At the other extreme, it's easy to say something about the case $c=n^2$. If each node is a different color, then you can always extend by one node at each move, and you can never extend by more than one node, so an optimal strategy will take $n^2-1$ moves.

So now we just have to fill in all the cases in between....

Related Question