import random
def rps_game():
options = ["가위", "바위", "보"]
# AI가 이겼을 때 사용할 멘트 모음
ai_win_messages = [
"후후, 아직 인간의 판단력으로는 부족하군요.",
"데이터는 거짓말을 하지 않습니다. 제가 이겼습니다.",
"연산 속도 차이가 승부를 갈랐네요.",
"인간의 직감은 흥미롭지만, 정확도는 제가 더 높습니다.",
"오늘은 AI가 한 수 위네요. 다음엔 더 분발해 보세요.",
"예측 완료. 결과는 제 승리입니다.",
"이 정도면 연습 모드였다고 해도 되겠죠?",
"인간의 패턴, 이미 분석이 끝났습니다.",
"확률적으로도 제가 이길 수밖에 없는 판이었습니다."
]
print("\nAI와 가위바위보 대결!")
user_choice = input("가위, 바위, 보 중 하나를 선택하세요: ")
# 1. 입력값 검증
if user_choice not in options:
print("잘못 입력하셨습니다. 가위, 바위, 보 중에서 정확히 입력해주세요.")
return
ai_choice = random.choice(options)
print(f"나: {user_choice} / AI: {ai_choice}")
# 2. 승패 판정
if user_choice == ai_choice:
print("비겼네요! 한 판 더?")
elif (user_choice == "가위" and ai_choice == "보") or \
(user_choice == "바위" and ai_choice == "가위") or \
(user_choice == "보" and ai_choice == "바위"):
print("대단해요! 당신이 승리했습니다!")
else:
print("AI:", random.choice(ai_win_messages))
# 3. 연속 플레이 기능 추가
while True:
rps_game()
again = input("다시 할까요? (y/n): ")
if again.lower() != "y":
print("게임을 종료합니다. 수고하셨습니다.")
break# Online Python compiler (interpreter) to run Python online.
# Write Python 3 code in this online editor and run it.
print("Try programiz.pro")