A question about the minesweeper game

I'll prove that the maximum $M\geq 2mn-m-n$.

A way to compute the sum is putting a stick that joins every pair of consecutive squares such that one of them has mine and the other hasn't. The number of sticks is equal to the sum of the numbers.

In a checkered board there are no diagonal sticks, but there is every possible vertical and horizontal stick. In each row, there are $m-1$ sticks, and in each column there are $n-1$ sticks. This makes

$$m(n-1)+n(m-1)=2mn-m-n$$

EDIT: This is not the maximum, as I thought. Suppose that there is an odd number $n$ of rows. Fill odd rows with mines and leave blank the even ones. If there is more than one column, the blanks in the border are filled with $4$'s and the rest with $6$'s. This makes $$6(m-2)\frac{n-1}2+2\cdot4\cdot\frac{n-1}2=3mn-3m-2n+2$$ which is greater than the other bound except for very small values of $m$ and $n$ (one-row or one-column boards and such).


I'll prove that the maximum $M \leq 3nm - 2n - 2m + 2$.

First, note that if we assign to a bomb the number of non-bomb neighbors, the total sum doubles. Thus, we can obtain a more symmetric problem, which will be useful in what follows. (We could also just show that swapping all blank tiles with bombs and vice versa does not change the sum.)

For what follows, values will refer to the value in this alternate formulation.

Let there be a bomb in the interior of the board with seven clear neighbors (and thus, zero or one bomb neighbors). Then one of the orthogonally-adjacent cells has four known clear neighbors and one known bomb neighbor. (If there is no neighboring bomb, then choose any orthogonally-adjacent tile; if the neighboring bomb is orthogonally adjacent, choose the clear cell directly opposite the bomb; if the neighboring bomb is diagonal, then choose either of the cells on the two opposite edges.)

Since that cell has 4 clear neighbors and 1 bomb neighbor, it has a maximum value of 4 (if on the interior), and 1 (if on the border). Adding a bomb to that cell will add one to the values of its clear neighbors and not decrease its own value.

The same argument applies to clear cells with seven neighboring bombs.

So we see that we may assume that interior cells have a maximum value of 6.

Similarly, we will show that, optimally, border cells do not attain a value of 5.

For if a bomb on the border has five clear neighbors, the neighbor opposite the border has four clear neighbors and one bomb neighbor; the same argument as above applies.

So we may assume that border cells have a maximum value of 4.

So an upper bound for the maximum sum (in the original problem) is \begin{align} M & \leq \frac{1}{2}\left(6(m-2)(n-2) + 4(2(m-2) + 2(n-2)) + 3\cdot 4 \right) \\ & = 3(m-2)(n-2) + 5(m-2) + 5(n-2) + 6 \\ & = 3mn - 2m - 2n + 2. \end{align} We've only shown this upper bound for when $m,n \geq 2$, but this bound happens to work for the $1\times n$ case, where it reduces to $n$, which is greater that the actual maximum of $n-1$.

Note that a pattern of stripes, as shown by user ajotaxte, produces a lower bound of $$M \geq 3mn - 3m - 2n + 2.$$

In conclusion, we see that the maximum for $m\times n$ grids, with $m \leq n$, is $$ 3mn - 3m - 2n + 2 \leq M \leq 3mn - 2m - 2n + 2.$$