Hi, Im doing this memory game where im supposed to randomize 18 words from a file, duplicate them and shuffle and then place in a matrix 6 x 6. Ive gotten quite far, but im not sure what the best way is to place the words in the matrix, and been searching for ways a couple of days but cant find much info about this.
The "player" is supposed to pick 2 words and then i need to compare them, but right now i cant get passed the matrix bit. One of my friends thought we could make a list with a fixed size like list = [6][6], but then i get errors... can i do it in the way i intended or should i just go about it a totally different way?? Kind regards / Suzy
import random
class Ruta:
def __init__(self, ord ):
self.ord = ord
self.hidden = True
def turn(self):
if self.hidden == True:
self.hidden = False
else:
self.hidden = True
def __str__(self):
if self.hidden:
return "---"
else:
return self.ord
def main():
infile = open("memo.txt", "r")
words = []
valdaord = []
words = infile.readlines()
infile.close()
random.shuffle(words)
index = 0
while index < 18:
valdaord.append(words[index].rstrip('\n'))
valdaord.append(words[index].rstrip('\n'))
index += 1
random.shuffle(valdaord)
print len(valdaord)
liobj = []
for ord in valdaord:
R = Ruta(ord)
liobj.append(R)
matobj = [6][6]
a = 0
for i in range(0,5):
matobj[0][a] = liobj[i]
a = a + 1
a = 0
for i in range(6,11):
matobj[1][a] = liobj[i]
a = a + 1
a = 0
for i in range(12,17):
matobj[2][a] = liobj[i]
a = a + 1
a = 0
for i in range(18,23):
matobj[3][a] = liobj[i]
a = a + 1
a = 0
for i in range(24,29):
matobj[4][a] = liobj[i]
a = a + 1
a = 0
for i in range(30,35):
matobj[5][a] = liobj[i]
a = a + 1
bokstav = ['', 'A', 'B', 'C', 'D', 'E', 'F']
sifferlista = ['','1','2','3','4','5','6',]
for i in range (0,6):
for j in range(0,6):
if j==0:
print bokstav[i]
elif i==0:
print sifferlista[j]
print li_bredd[i,j]
main()
gameover = False
while !gameover:
gissning = 0.0
bok = raw_input('Vilken rad? (A-F)').lower()
bok = strIn[0]
siffra = input('Vilken kolumn? (1-6)')
siffra = strIn[1]
if bok =='A';
index = 0
elif bok == 'B';
index = 1
elif bok == 'C';
index = 2
elif bok == 'D';
index = 3
elif bok == 'E';
index = 4
elif bok == 'F';
index = 5
gissning = gissning + 0.5
if all is turned
gameover = True
and some more code...