I have to add mines (in this case 35 mines) on to a 2d list(field). The field is created like this.
field = []
for row in range(10):
field.append([])
for col in range(15):
field[-1].append(" ")
I also have a list of tuples that represent free squares where mines can be placed.
free = []
for x in range(15):
for y in range(10):
free.append((x, y))
What I thought of doing was getting a random sample from the free squares with random.sample(free, 35) but I don't know how to place mines into the field according to the random sample I have gotten.
Aucun commentaire:
Enregistrer un commentaire