Probability Based on a Grid of Lights The question is as follows :
A grid of $n\times n$ ($n\ge 3$) lights is connected to a switch in such a way that each light has a $50\%$ chance of lighting up when switched on. What is the probability that we see a closed curve after turning on the switch?

*

*A closed curve is basically a set of any number of lines that enclose an area (containing at least one light). The lines could be vertical, horizontal, or diagonal only (that is, making angles $0°, 90°$ or $45°$ with the horizontal), otherwise the curve would not be closed.


*A line is a line segment joining two illuminated lights.


*We only say a closed curve is formed, when all the lights except the ones that make up the boundary of the shape are switched off.


*To check if any configuration satisfies these conditions, connect all the lights (that you claim to be part of the boundary of a shape) through lines. If there’s any other illuminated light left out, then this configuration is invalid.


*Every illuminated light must be immediately next to at least one of the grid points that the curve encloses. As an example for what ‘immediately next to’ means, consider the $5\times5$ grid:  $$\begin{matrix} 1&2&3&4&5 \\ 6& \color{blue}7 & \color{blue}8 &\color{blue}9 &10 \\ 11&\color{blue}{12} &\color{red}{13} & \color{blue}{14} & 15   \\16 & \color{blue}{17}&\color{blue}{18}&\color{blue}{19} &20 \\ 21&22&23&24&25 \end{matrix} $$
Here, the blue lights are immediately next to $13$.

This problem essentially comes down to counting the total number of such closed curves in an $n\times n$ grid. So I figured I might as well start off with the easy part.
Now, every single configuration of the grid occurs with an equal probability of $P=\frac{1}{2^{n^2}}$ (as there are a total of $2^{n^2}$ cases possible). So, the required probability will be the number of possible closed curves $\space \times P$. How can I determine all the closed curves?
 A: This is just a way to start thinking about it, not a full solution.
Let's start with smaller numbers and see what happens.  For $3\times 3$ grids:
$$\begin{matrix} 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9\end{matrix}$$ 
there are $2^4 = 16$ configurations that work. You need at least $\{2,4,6,8\}$ and you may have any of the following also: $\{1,3,7,9\}$. 
So, that is $\dfrac{2^4}{2^9} = \dfrac{1}{32}$.
For a $4\times 4$ grid:
$$\begin{matrix}1 & 2 & 3 & 4 \\ 5 & 6 & 7 & 8 \\ 9 & 10 & 11 & 12 \\ 13 & 14 & 15 & 16\end{matrix}$$
There are $2^4$ configurations each to surround $6,7,10,11$. There are $2^4$ ways to surround any pair $(6,7), (6,10), (7,11), (10,11)$. For $(6,11)$ or $(7,10)$, you can surround them by $2,5,7,10,12,15$ or $3,6,8,9,11,14$ respectively. And there are $2^6$ ways to choose from the corners of the enclosure. Consider a configuration surrounding $(6,7,10)$. You need at least $2,3,5,8,9,11,14$, but you may include any of $1,4,12,13,15$, so there are $2^5$ ways to surround them, and similarly for $(6,7,11), (7,10,11), (6,10,11)$. And finally, if you have all four of the center ones surrounded, you need at least $2,3,5,8,9,12,14,15,16$, and you may or may not include $1,4,13,16$ at your whim.
So, that is:
$$\frac{4\cdot 2^4+4\cdot 2^4 + 2\cdot 2^6 + 4\cdot 2^5+2^4}{2^{16}} = \dfrac{25}{4096}$$
I am not seeing an easy pattern to extend this. As the enclosed area in the center become more complicated, it seems the number of possible ways to surround it becomes more complicated as well.
This appears closely related to the number of ways to claim an area in Go.
