Created
April 12, 2016 10:29
-
-
Save Shinmuscle/c77a8bb6e8e81dce5ab7c33987f6bbe6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def check_tic_tac_toe(matrix): | |
#bovenste rij | |
if matrix[0][0] == matrix[0][1] == matrix[0][2]: | |
print("player ", matrix[0][0], " won!") | |
#rechter kolom | |
if matrix[0][2] == matrix[1][2] == matrix[2][2]: | |
print("player ", matrix[0][2], " won!") | |
#onderste rij | |
if matrix[2][0] == matrix[2][1] == matrix[2][2]: | |
print("player ", matrix[2][0], " won!") | |
#linker kolom | |
if matrix[0][0] == matrix[1][0] == matrix[2][0]: | |
print("player ", matrix[0][0], " won!") | |
#diagonaal links-boven naar rechts-onder | |
if matrix[0][0] == matrix[1][1] == matrix[2][2]: | |
print("player ", matrix[0][0], " won!") | |
#diagonaal rechts-boven naar links-onder | |
if matrix[0][2] == matrix[1][1] == matrix[2][0]: | |
print("player ", matrix[0][2], " won!") | |
game = [[1, 2, 0],[2, 1, 0],[2, 1, 1]] | |
check_tic_tac_toe(game) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment