Jan-14-2021, 04:12 PM
You seem to have a 5x5 board.
I like gravity to play it's role,
coins drop to the lowest position possible vertically (like in a real game)
So the user only needs to enter a column of choice (x-axis), the y value is automatically
determined by how many coins are already in that column.
A user entry is an x,y element in your 2D list (matrix) that turns into an X or an O.
Then you need 3 validation routines that loop over the matrix:
-one that counts how many of the same are on each row (adjacent)
-in each column
-and diagonally (a bit more tricky index-wise)
If one of the counts gets to 4, you have a winner.
Paul
I like gravity to play it's role,
coins drop to the lowest position possible vertically (like in a real game)
So the user only needs to enter a column of choice (x-axis), the y value is automatically
determined by how many coins are already in that column.
A user entry is an x,y element in your 2D list (matrix) that turns into an X or an O.
Then you need 3 validation routines that loop over the matrix:
-one that counts how many of the same are on each row (adjacent)
-in each column
-and diagonally (a bit more tricky index-wise)
If one of the counts gets to 4, you have a winner.
Paul