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)
‘————————————‘
wumpus_location
=
choice(cava_numbers)
player_location
=
choice(cava_numbers)
while
player_location==wumpus_location:
player_location=choice(cava_numbers)
“Welcome
to
Hunt
the
Wumpus!”
“You
can
see”,len(cava_numbers),”cavas”
“To
play,just
type
the
number”
“of
the
cava
you
wish
to
enter
next”
while
True:
“You
are
in
cava”,player_location
“From
here,you
can
see
three
cavas:”,cavas[player_location]
if
wumpus_location
in
cavas[player_location]:
“I
smell
a
Wumpus”
今天的文章python完整游戏代码_PYTHON小游戏代码分享到此就结束了,感谢您的阅读。
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
如需转载请保留出处:https://bianchenghao.cn/10123.html