Created
September 21, 2017 21:56
-
-
Save Gwith/65a693bd86bd9e2704f9201975df8eb9 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| import random | |
| ai_marker = 'X' | |
| matrix = [ | |
| ['7', '8', '9'], | |
| ['4', '5', '6'], | |
| ['1', '2', '3'] | |
| ] | |
| marked_spots = [] | |
| tries = 0 | |
| while (tries != 1): | |
| location = random.choice(list(range(1, 9))) | |
| for i, row in enumerate(matrix): | |
| for j, value in enumerate(row): | |
| if (location != 'X') and (location != 'O') and (location not in marked_spots) and (value == location): | |
| matrix[i][j] = ai_marker | |
| marked_spots.append(location) | |
| tries += 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment