Random No.
Random No.
In [1]:
for i in range(len(board)):
for j in range(len(board)):
if board[i][j] == 0:
l.append((i, j))
return(l)
for y in range(len(board)):
if board[x, y] != player:
win = False
continue
if win == True:
return(win)
return(win)
for y in range(len(board)):
if board[y][x] != player:
win = False
continue
if win == True:
localhost:8888/nbconvert/html/Untitled1.ipynb?download=false 2/4
4/17/2020 Untitled1
return(win)
return(win)
winner = player
while winner == 0:
for player in [1, 2]:
board = random_place(board, player)
print("Board after " + str(counter) + " move")
print(board)
sleep(2)
counter += 1
winner = evaluate(board)
if winner != 0:
break
return(winner)
# Driver Code
print("Winner is: " + str(play_game()))
localhost:8888/nbconvert/html/Untitled1.ipynb?download=false 3/4
4/17/2020 Untitled1
[[0 0 0]
[0 0 0]
[0 0 0]]
Board after 1 move
[[0 0 0]
[1 0 0]
[0 0 0]]
Board after 2 move
[[0 0 0]
[1 0 0]
[2 0 0]]
Board after 3 move
[[0 1 0]
[1 0 0]
[2 0 0]]
Board after 4 move
[[0 1 2]
[1 0 0]
[2 0 0]]
Board after 5 move
[[0 1 2]
[1 1 0]
[2 0 0]]
Board after 6 move
[[0 1 2]
[1 1 0]
[2 0 2]]
Board after 7 move
[[1 1 2]
[1 1 0]
[2 0 2]]
Board after 8 move
[[1 1 2]
[1 1 2]
[2 0 2]]
Winner is: 2
In [ ]:
In [ ]:
localhost:8888/nbconvert/html/Untitled1.ipynb?download=false 4/4