石头,布,剪刀!Python游戏。分数和赢家的输出不变

2024-06-25 23:38:55 发布

您现在位置:Python中文网/ 问答频道 /正文

我目前正在尝试编程一块石头,布,剪刀!Python游戏。我面临的问题是,当我赢了,比分似乎没有改变,当我赢了,电脑仍然说我输了。顺便说一句,这都是我自己的编程,我才刚上6年级。这是我的代码:

print("Welcome to my Rock, Paper, Scissors! game. Its quite simple. 'R' = Rock, 'P' = Paper and 'S' = Scissors. All of your inputs must begin with a capital letter. Good luck! Here we go!")
import random
Computer_RPS = ["Rock", "Paper", "Scissors"]

def RPS():
    Cpoints = 0
    Upoints = 0
    one = 1
    User_choice1 = input("Rock, Paper, Scissors!...")
    Computer_choice1 = (random.choice(Computer_RPS))
    """
    while (User_choice1 != "Rock" or "Paper" or "Scissors" or "R" or "P" or "S"):
        User_choice1 = input("That value is not valid. Lets try again; Rock, Paper, Scissors!...")
    """
    if User_choice1 == Computer_choice1:
        print("Draw. Getting tense!...")
        print("I chose:" + (Computer_choice1))
        print("The score stands at: " + str(Cpoints) + " to me and " + str(Upoints) + " to you.")
    elif Computer_choice1 == "Rock" and User_choice1 == "S" or "Scissors":
        (Cpoints) + (one)
        print("Good try. Better luck next time!")
        print("I chose:" + (Computer_choice1))
        print("The score stands at: " + str(Cpoints) + " to me and " + str(Upoints) + " to you.")
    elif Computer_choice1 == "Paper" and User_choice1 == "R" or "Rock":
        (Cpoints) + (one)
        print("Unlucky. But that means 1 point to me!")
        print("I chose:" + (Computer_choice1))
        print("The score stands at: " + str(Cpoints) + " to me and " + str(Upoints) + " to you.")
    elif Computer_choice1 == "Scissors" and User_choice1 == "P" or "Paper":
        (Cpoints) + (one)
        print("Unlucky. But that means 1 point to me!")
        print("I chose:" + (Computer_choice1))
        print("The score stands at: " + str(Cpoints) + " to me and " + str(Upoints) + " to you.")
    else:
        print("Well Done! You beat me.  :'-(   Never mind. One point to you.")
        Upoints += 1

RPS()
RPS()
RPS()

下面是我的代码及其输出的屏幕截图: My code and its output.

任何帮助我都将不胜感激。谢谢你抽出时间来读我的问题。在


Tags: orandtocomputerpapermeprintscissors