Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Casella:
- def __init__(self, posX, posY):
- self.posX = posX
- self.posY = posY
- occupato=False
- simbolo=""
- tris = []
- for i in range(3):
- for y in range(3):
- tris.append(Casella(i,y))
- posizioni = [[0,0],[0,1],[0,2],[1,0],[1,1],[1,2],[2,0],[2,1],[2,2]]
- def scelta(simbolo, num):
- for casella in tris:
- while (casella.occupato):
- if (casella.posX == posizione[num][0] and casella.posY == posizione[num][1]):
- casella.occupato = True
- casella.simbolo = simbolo
- print("----------------")
- print("| 1 | 2 | 3 |")
- print("----------------")
- print("| 4 | 5 | 6 |")
- print("----------------")
- print("| 7 | 8 | 9 |")
- print("----------------")
- persona1=input("Scrivi nome 1: ")
- persona2=input("Scrivi nome 2: ")
- fine=False
- def disegnaTabella():
- print("----------------")
- pos1=[]
- for casella in tris:
- if (casella.posX == 0):
- pos1.append(casella.simbolo)
- print("| "+str(pos1[0])+" | "+str(pos1[1])+" | "+str(pos1[2])+" |")
- print("----------------")
- pos2=[]
- for casella in tris:
- if (casella.posX == 1):
- pos2.append(casella.simbolo)
- print("| "+str(pos2[0])+" | "+str(pos2[1])+" | "+str(pos2[2])+" |")
- print("----------------")
- pos3=[]
- for casella in tris:
- if (casella.posX == 2):
- pos3.append(casella.simbolo)
- print("| "+str(pos3[0])+" | "+str(pos3[1])+" | "+str(pos3[2])+" |")
- print("----------------")
- tris[0].simbolo="X";
- disegnaTabella()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement