Dear, I have a query, how can I make a board or array of matrices in Python ?, whereas the matrix that will form my board or main matrix is a class (has the taxes to be able to rotate and fill in data inside from that same matrix)
class matriz:
def __init__(self):
self.t = [[0,0,0],
[0,0,0],
[0,0,0]]
def __str__(self):
txt =""
txt +=str(self.t[0][0])+str(self.t[0][1])+str(self.t[0][2])+"\n"
txt +=str(self.t[1][0])+str(self.t[1][1])+str(self.t[1][2])+"\n"
txt +=str(self.t[2][0])+str(self.t[2][1])+str(self.t[2][2])
return txt
def casilla_vacia(self, f, c):
libre=self.t[f][c]==0
return libre
def rellenar_casilla(self,f,c,j):
libre=self.casilla_vacia(f,c)
if libre:
self.t[f][c]=j
return True
else:
return False
def nada_libre(self):
ocupado= ((not 0 in self.t[0]) and
(not 0 in self.t[1]) and
(not 0 in self.t[2]))
return ocupado
def girar_izquierda(self):
new_m = [[0,0,0],
[0,0,0],
[0,0,0]]
new_m[0][0]=self.t[0][2]
new_m[1][0]=self.t[0][1]
new_m[2][0]=self.t[0][0]
new_m[0][1]=self.t[1][2]
new_m[2][1]=self.t[1][0]
new_m[0][2]=self.t[2][2]
new_m[1][2]=self.t[2][1]
new_m[2][2]=self.t[2][0]
print(self)
def girar_derecha(self):
new_ma = [[0,0,0],
[0,0,0],
[0,0,0]]
new_ma[0][0]=self.t[2][0]
new_ma[1][0]=self.t[2][1]
new_ma[2][0]=self.t[2][2]
new_ma[0][1]=self.t[1][0]
new_ma[2][1]=self.t[1][2]
new_ma[0][2]=self.t[0][0]
new_ma[1][2]=self.t[0][1]
new_ma[2][2]=self.t[0][2]
print(self)
tab= matriz()
basically I want to make a matrix, but in which each element of that matrix is a 3X3 matrix that is defined in the code above