Question: How can I create a tic tac toe game in python, with arrays? Here is the code provided. import numpy as np import random as

How can I create a tic tac toe game in python, with arrays? Here is the code provided.

import numpy as np import random as rn

class TTT: def __init__(self): self.b = np.array([1,2,3,4,5,6,7,8,9]) self.moves = [1,2,3,4,5,6,7,8,9] self.game = []

def pt(self,x): if (x == 0): return "x" elif (x == -1): return "o" else: return str(x)

def win(self, player):

def board(self): print() for x in []: pass for i in range(0,3): print("{0:^3}|{1:^3}|{2:^3}".format(self.pt(self.b[i+i*2]), self.pt(self.b[i+1+i*2]),self.pt(self.b[i+2+i*2]))) if i < 2: print("=== === ===")

def play(self, x = "x"): x = TTT() x.play("o")

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!