Checking for victory
Applying rules to correctly place discs is not enough: you have to check if a player's move makes him win the game. You know a player wins the game when he connects four (or more) discs next to each other horizontally, vertically, or diagonally.
So we need to check for victory.
The idea: A very cheap way to check for a victory would be scanning the entire field at every turn, disc after disc, until you find four discs in a row. I don't want you to use brute force to check for victory, so let's have a deeper look at game mechanics.
According to Connect Four rules, we can say:
- A player can win, but cannot lose during his turn. There's no way a player can end the game during his turn, unless he wins. This means when red plays, ...