python完整游戏代码_PYTHON小游戏代码

python完整游戏代码_PYTHON小游戏代码fromrandomimportchoicecava_numbers=range(0,20)cavas=[]foriincava_numbers:cavas.append([])unvisited_cavas=range(0,20)visited_cavas=[0]unvisited_cavas.remove(0)whileunvisited_cavas!=[]:i=choice(visited_…

from

random

import

choice

cava_numbers

=

range(0,20)

cavas

=

[]

for

i

in

cava_numbers:

cavas.append([])

unvisited_cavas

=

range(0,20)

visited_cavas

=

[0]

unvisited_cavas.remove(0)

while

unvisited_cavas

!=

[]:

i

=

choice(visited_cavas)

if

len(cavas[i])>=3:

continue

next_cava

=

choice(unvisited_cavas)

cavas[i].append(next_cava)

cavas[next_cava].append(i)

visited_cavas.append(next_cava)

unvisited_cavas.remove(next_cava)

for

i

in

cava_numbers:

while

len(cavas[i])<3:

passage_to

=

choice(cava_numbers)

cavas[i].append(passage_to)

print

‘————————————‘

wumpus_location

=

choice(cava_numbers)

player_location

=

choice(cava_numbers)

while

player_location==wumpus_location:

player_location=choice(cava_numbers)

print

“Welcome

to

Hunt

the

Wumpus!”

print

“You

can

see”,len(cava_numbers),”cavas”

print

“To

play,just

type

the

number”

print

“of

the

cava

you

wish

to

enter

next”

while

True:

print

“You

are

in

cava”,player_location

print

“From

here,you

can

see

three

cavas:”,cavas[player_location]

if

wumpus_location

in

cavas[player_location]:

print

“I

smell

a

Wumpus”

今天的文章python完整游戏代码_PYTHON小游戏代码分享到此就结束了,感谢您的阅读。

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
如需转载请保留出处:https://bianchenghao.cn/10123.html

(0)
编程小号编程小号

相关推荐

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注