Created
May 4, 2019 21:21
-
-
Save googkhan/a04540a51071347c2ed9613326dc3ffc to your computer and use it in GitHub Desktop.
xox trials
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 | |
| board = [[ '', '', ''], | |
| ['', '', ''], | |
| ['', '', '']] | |
| empty_points = [[0,0], [0,1], [0,2], | |
| [1,0], [1,1], [1,2], | |
| [2,0], [2,1], [2,2]] | |
| solution = ['x', 'o', 'x'] | |
| def play(): | |
| while True: | |
| x = int(input("Satır giriniz: ")) - 1 | |
| y = int(input("Sütun giriniz: ")) - 1 | |
| if 2 >= x >= 0 or 2 >= y >= 0: | |
| pass | |
| else: | |
| print("123 gir") | |
| p = input("x ya da o giriniz: ") | |
| if p not in ['o', 'x']: | |
| print('Sadece x yada o giriniz.') | |
| break | |
| ## board[1,1] = 'x' | |
| board[x][y] = p | |
| sutunlar=[[board[0][0],board[1][0],board[2][0]], | |
| [board[0][1],board[1][1],board[2][1]], | |
| [board[0][2],board[1][2],board[2][2]]] | |
| capraz =[[board[0][0],board[1][1],board[2][2]], | |
| [board[0][2],board[1][1],board[2][0]]] | |
| print(board) | |
| # empty_points.remove([x,y]) | |
| # deger_ai=random.randrange(0,2) | |
| # satir_ai=random.choice(empty_points)[0] | |
| # sutun_ai=random.choice(empty_points)[1] | |
| # xox[satir_ai][sutun_ai]=deger_ai | |
| # empty_points.remove([satir_ai,sutun_ai]) | |
| empty_points.remove([x, y]) | |
| deger_ai = random.choice(['x', 'o']) | |
| satir_ai = random.choice(empty_points) | |
| sutun_ai = random.choice(empty_points) | |
| board[satir_ai][sutun_ai] = deger_ai | |
| # for i in xox: | |
| # print(i) | |
| # | |
| # for i in xox: | |
| # if set(i)==solution1 or set(i)==solution2: | |
| # print("---tebrikler kazandınız---") | |
| # | |
| # for i in sutunlar: | |
| # if set(i)==solution1 or set(i)==solution2: | |
| # print("---tebrikler kazandınız---") | |
| # | |
| # for i in capraz: | |
| # if set(i)==solution1 or set(i)==solution2: | |
| # print("---tebrikler kazandınız---") | |
| play() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment