As part of my course work to create a minesweeper-like game, I have been trying to generate a list of 15 coordinates and then take the first 5 towards Bandits and 10 towards my Treasure Chests.
I have been trying to sort these as they will be placed upon a 8x8 grid containing unique coords for both my chests and bandits, I have the following code, however, when printing each list, my coordinates seem to be the exact same.
def positions():
import random
List=[]
emptylist=[]
while (len(emptylist)<20):
List.append([random.randint(1,8),random.randint(1,8)])
while List ==[1,1]:
List.remove([1,1])
print ("origin removed")
[emptylist.append(x) for x in List if x not in emptylist]
print("-------------------")
print(" BANDIT COORDS")
print("-------------------")
for x in range(0,5):
#print(emptylist[x])
Bandits=[]
[Bandits.append(emptylist[x]) for v in emptylist if v not in Bandits]
print(Bandits[x])
print("-------------------")
print(" CHEST COORDS")
print("-------------------")
for y in range(6,16):
# print(emptylist[y])
Chests=[]
[Chests.append(emptylist[y]) for v in emptylist if v not in Chests]
print(Chests[y])
print()
# Used to check the complete list
#print(emptylist)
I have used printing to debug the coordinates while they will not appear in the real game.
Aucun commentaire:
Enregistrer un commentaire