Two players alternate coloring $3\times 3$ squares in $n\times m$ rectangle

52 Views Asked by At

So I'm writing a game and I'm supposed to implement optimal play from the computer's part, however I cannot find any strategies.

The game is played on $n\times m$ board. Each turn a player selects one uncolored square then colors it and all other squares around it (a total of $9$), which means that those colored squares cannot be selected again.

The player who is unable to select a square loses (so the one with the last step wins).

The only thing I could come up with is that if $n,m$ are both odd, the starting player can win by starting in the middle and then mirroring all the steps.