Chance of a group of adjacent grid spaces sharing a value. Given a grid of spaces ( 8 * 8 in my case ). If you were to choose a random number between 1-3 for each space, what is the probability of creating a 'group'? Where a 'group' is defined as any set of three or more pieces who share the same number designation and are each connected to another by a side (i.e. not diagonally).
I have made a puzzle game for a mobile platform; the game requires players to organise pieces and delete 'groups'. The pieces are chosen at random (insofar as the system allows) and can be either red, green or blue. I imagined the incidence of initial groups to be lower than it is, but found the calculations were either too complex or I was complicating them. I would benefit from a solution for an 8*8 grid with 1/3 chance for each space, but most of all I need someone to explain the working.
 A: This doesn't directly answer your question, but it's something I know how to compute. I will consider only $3$-groups (3 in a row horizontally or vertically), and will compute the expected number of them.  I'm ignoring L-shaped groups; including these will increase the answer substantially.
Each row has six possible 3-groups, and there are 8 rows, for 48 possible horizontal 3-groups.  By symmetry, there are 48 possible vertical 3-groups, so 96 possible 3-groups altogether.  Consider the 96 random variables, each corresponding to one of these 3-groups.  Each random variable has expected value $1/9$, since by choosing the three positions at random we have a 3-group for 3 of the 27 possible choices.  By linearity of expectation, the total number of 3-groups is the sum over all 96 random variables, or $\frac{96}{9}=10.\overline{6}$.
Based on this, I expect the probability of having at least one $3$-group is high.  I have no idea how to compute it analytically, but Monte Carlo methods would probably be helpful here (generate 10K or 100K such grids and test each one).
Update: As per request, I'll also consider $L$-shaped groups of 3.  Oriented in this specific way, there are 7 whose base is on the bottom row, and the same on all rows but the top. Hence there are 49 $L$-shapes in this orientation.  But there are three other orientations, so together there are 196 possible $L$-shaped groups.  Each also has an expected value of $1/9$, so there will be a total of $\frac{196}{9}$ expected $L$-shapes.  Combining with the above there will be $\frac{292}{9}=32.\overline{4}$ expected $L$ or $3$-groups.  Quite a few!
