作为创建类似扫雷游戏的课程工作的一部分,我一直在尝试生成一个包含15个坐标的列表,然后将前5个坐标带向土匪,10个坐标带向我的宝箱。你知道吗
我一直在尝试排序,因为它们将被放置在一个8x8网格上,其中包含我的胸部和强盗的唯一坐标,我有以下代码,但是,当打印每个列表时,我的坐标似乎是完全相同的。你知道吗
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)
我已经使用打印调试坐标,而他们不会出现在真正的游戏。你知道吗
目前没有回答
相关问题 更多 >
编程相关推荐