python小游戏 雷方块小解密
2021/11/15 14:09:40
本文主要是介绍python小游戏 雷方块小解密,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
点击一个它和他相邻的方块会加1
数组里数字全相同成功
import random
def result(list_1,n):
max_num = 3
list_2 = [n-2,n-1 , n]
list_3 = [True ,True ,True]#是否+1表
length = len(list_1)
for i in list_2:
if i < 0 or i >= length:
list_3[list_2.index(i)] = False
continue
#print(list_3)
for i in range(0,3):
if list_3[i]:
list_1[list_2[i]] += 1
if list_1[list_2[i]] > max_num:
list_1[list_2[i]] = 1
#print(list_1)
return list_1
def demo(list_1,list_2):
yep = True
a = list_1[0]
for i in list_1:
if i == a:
a == i
else:
yep = False
break
if yep and len(list_2) < 7:
return list_2
else:
x = random.randint(1,len(list_1))
list_2.append(x)
list_1 = result(list_1,x)
return demo(list_1,list_2)
def game(lis):
num=int(input("请输入数值:"))
lis= result(lis,num)
return lis
#print(game([1,2,3,2]))
lis = [1,2,1,3]
while(True):
try:
lis_1 = lis.copy()
answer = demo(lis_1,[])
print(answer)
break
except:
pass
yep = True
print(lis)
while(yep):
lis = game(lis)
print(lis)
a = lis[0]
for i in lis:
if i == a:
a == i
yep = False
else:
yep = True
break
if not yep :
print("You are winner!")
这篇关于python小游戏 雷方块小解密的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-05-08有遇到过吗?同样的规则 Excel 中 比Python 结果大
- 2024-03-30开始python成长之路
- 2024-03-29python optparse
- 2024-03-29python map 函数
- 2024-03-20invalid format specifier python
- 2024-03-18pool.map python
- 2024-03-18threads in python
- 2024-03-14python Ai 应用开发基础训练,字符串,字典,文件
- 2024-03-13id3 algorithm python
- 2024-03-13sum array elements python