Пользователь должен взаимодействовать с игрой с помощью командной строки: разработать простой интерфейс, отображающий параметры игры (камень, ножницы, бумага).

Откройте редактор и напишите следующий код:

import random

# Game choices
choices = ["rock", "paper", "scissors"]

# Function to determine the winner
def determine_winner(user_choice, computer_choice):
    if user_choice == computer_choice:
        return "It's a draw!"
    elif (
        (user_choice == "rock" and computer_choice == "scissors")
        or (user_choice == "paper" and computer_choice == "rock")
        or (user_choice == "scissors" and computer_choice == "paper")
    ):
        return "You win!"
    else:
        return "You lose!"

# Function to play the game
def play_game(user_choice):
    computer_choice = random.choice(choices)
    result = determine_winner(user_choice, computer_choice)
    return f"You chose {user_choice}, the computer chose {computer_choice}.\n{result}"

# Main function
def main():
    print("Welcome to Rock, Paper, Scissors!")

    while True:
        user_choice = input("Choose rock, paper, or scissors (or q to quit): ").lower()

        if user_choice == "q":
            break

        if user_choice not in choices:
            print("Invalid choice. Please try again.")
            continue

        print(play_game(user_choice))

    print("Thanks for playing!")

# Execute the game
if __name__ == "__main__":
    main()

Чтобы запустить код локально, вы можете сохранить его в файле с именем rock_paper_scissors.py и выполнить с помощью интерпретатора Python: python rock_paper_scissors.py.

Предоставленный код является упрощенной версией игры и не включает обработку ошибок или дополнительные функции. Не стесняйтесь настраивать и улучшать его в соответствии с вашими требованиями.

Все сделано.