import random
def get_user_choice():
user_input = input("กรุณาเลือก: กรรไกร (1), กระดาษ (2), ค้อน (3): ")
choices = {"1": "กรรไกร", "2": "กระดาษ", "3": "ค้อน"}
return choices.get(user_input, None)
def get_computer_choice():
choices = ["กรรไกร", "กระดาษ", "ค้อน"]
return random.choice(choices)
def determine_winner(user_choice, computer_choice):
if user_choice == computer_choice:
return "เสมอกัน!"
elif (user_choice == "กรรไกร" and computer_choice == "กระดาษ") or \
(user_choice == "กระดาษ" and computer_choice == "ค้อน") or \
(user_choice == "ค้อน" and computer_choice == "กรรไกร"):
return "คุณชนะ!"
else:
return "คุณแพ้!"
def play_game():
user_choice = get_user_choice()
if user_choice is None:
print("การเลือกไม่ถูกต้อง กรุณาลองอีกครั้ง.")
return
computer_choice
aW1wb3J0IHJhbmRvbQoKZGVmIGdldF91c2VyX2Nob2ljZSgpOgogICAgdXNlcl9pbnB1dCA9IGlucHV0KCLguIHguKPguLjguJPguLLguYDguKXguLfguK3guIE6IOC4geC4o+C4o+C5hOC4geC4oyAoMSksIOC4geC4o+C4sOC4lOC4suC4qSAoMiksIOC4hOC5ieC4reC4mSAoMyk6ICIpCiAgICBjaG9pY2VzID0geyIxIjogIuC4geC4o+C4o+C5hOC4geC4oyIsICIyIjogIuC4geC4o+C4sOC4lOC4suC4qSIsICIzIjogIuC4hOC5ieC4reC4mSJ9CiAgICByZXR1cm4gY2hvaWNlcy5nZXQodXNlcl9pbnB1dCwgTm9uZSkKCmRlZiBnZXRfY29tcHV0ZXJfY2hvaWNlKCk6CiAgICBjaG9pY2VzID0gWyLguIHguKPguKPguYTguIHguKMiLCAi4LiB4Lij4Liw4LiU4Liy4LipIiwgIuC4hOC5ieC4reC4mSJdCiAgICByZXR1cm4gcmFuZG9tLmNob2ljZShjaG9pY2VzKQoKZGVmIGRldGVybWluZV93aW5uZXIodXNlcl9jaG9pY2UsIGNvbXB1dGVyX2Nob2ljZSk6CiAgICBpZiB1c2VyX2Nob2ljZSA9PSBjb21wdXRlcl9jaG9pY2U6CiAgICAgICAgcmV0dXJuICLguYDguKrguKHguK3guIHguLHguJkhIgogICAgZWxpZiAodXNlcl9jaG9pY2UgPT0gIuC4geC4o+C4o+C5hOC4geC4oyIgYW5kIGNvbXB1dGVyX2Nob2ljZSA9PSAi4LiB4Lij4Liw4LiU4Liy4LipIikgb3IgXAogICAgICAgICAodXNlcl9jaG9pY2UgPT0gIuC4geC4o+C4sOC4lOC4suC4qSIgYW5kIGNvbXB1dGVyX2Nob2ljZSA9PSAi4LiE4LmJ4Lit4LiZIikgb3IgXAogICAgICAgICAodXNlcl9jaG9pY2UgPT0gIuC4hOC5ieC4reC4mSIgYW5kIGNvbXB1dGVyX2Nob2ljZSA9PSAi4LiB4Lij4Lij4LmE4LiB4LijIik6CiAgICAgICAgcmV0dXJuICLguITguLjguJPguIrguJnguLAhIgogICAgZWxzZToKICAgICAgICByZXR1cm4gIuC4hOC4uOC4k+C5geC4nuC5iSEiCgpkZWYgcGxheV9nYW1lKCk6CiAgICB1c2VyX2Nob2ljZSA9IGdldF91c2VyX2Nob2ljZSgpCiAgICBpZiB1c2VyX2Nob2ljZSBpcyBOb25lOgogICAgICAgIHByaW50KCLguIHguLLguKPguYDguKXguLfguK3guIHguYTguKHguYjguJbguLnguIHguJXguYnguK3guIcg4LiB4Lij4Li44LiT4Liy4Lil4Lit4LiH4Lit4Li14LiB4LiE4Lij4Lix4LmJ4LiHLiIpCiAgICAgICAgcmV0dXJuCiAgICAKICAgIGNvbXB1dGVyX2Nob2ljZQo=