player_number
variable should be sufficient for the new checker function. Now what the individual checking functions do is they each return whether or not they evaluate to true, and if so, they return a 1. If it's not, the function will evaluate to 0. I could have used a true
or false
, but those wouldn't be able to be manipulated in the way I need to.
def column_checker(column, board): if board[0][column] == board[1][column] == board[2][column]: return 1 else: return 0
Now, all of the functions that were written look like the one shown above. Then, for the actual checking function, I add them all up and see if the resulting number is greater than or equal to 1, at which point the game will say congratulations and then it will end. I have also decided to make a little easter egg where if the player gets more than 1 three-in-a-row at the same time, it would print ASCII art to the terminal. I wouldn't make it myself because I don't know how, so I'll find some on the internet.
No comments:
Post a Comment