I’m new to Java and I need some help with 2D arrays.
In short, it’s a 4×4 grid where each player decides which position to obtain via input.
Player1 uses “1”, player2 uses “2”. The winner is the person who occupies 2×2.
E.g.
1 2 0 0
0 1 1 2
2 1 1 2
2 0 0 0
Player 1 wins in this case. I have no problem deciding who of the two wins, but I can’t implement a correct draw check. E.g
1 2 1 2
1 2 1 2
1 2 1 2
It’s a draw game because no player obtained 2×2 in the grid. However, I have no idea how to detect that without breaking something else. 🙁
Any help is much appreciated.
If you know how to detect a winner there shouldn’t be a problem detecting if the game ended in a draw: