0

我是 python 新手,我只是在处理这个应用程序

import random

# create a sequence of words to choose from
WORDS = ("hello","goodbye","smile","evening","daytime")

#

# pick one word randomly from the sequence
word = random.choice(WORDS)

# create a variable to see if the guess is correct
correct = word

# create a jumbled version of the word
jumble =""
while word:
    position = random.randrange(len(word))
    jumble += word[position]
    word = word[:position] + word[(position + 1):]

# start the game
print( \
"""
        Welcome to the anagram quiz!

   Unscramble the letters to make a word.
(Press the enter key at the prompt to quit.)
""")
print ("The jumble is:", jumble)

guess = input("\nYour guess: ")
guess = guess.lower()

while (guess != correct) and (guess != ""):
    print ("Sorry, that's not it.")
    guess = input("Your guess: ")
    guess = guess.lower()

if guess == correct:
    print ("That's it!  You guessed it!\n")

print ("Thank you for playing.")

input("\n\nPress the enter key to exit.")

正如您所看到的那样,它混淆了一个单词让用户猜测这个词是什么,我需要能够改进这一点,以便用户在他们被卡住时得到提示并添加一个评分系统来奖励那些解决混乱的人无需提示。

我已经尝试了几个小时,但没有找到,请您帮我添加该功能。

谢谢你。

4

1 回答 1

2

对于提示部分:如果玩家猜错了指定次数,他可以选择要求提示。提示将是您生成的内容以及可供选择的单词序列,成对形式。所以当玩家被卡住时,你会有一个词和一个提示来给出它。

WORDS=[['hello','greeting'],['evening','sunset'],etc.]

至于分数部分:您可以进行基于时间的评分,他们每秒都会失去分数,直到他们猜对为止,或者基于猜测的评分,他们每猜错一次就会失去分数。

于 2013-01-24T01:37:54.893 回答