import random win = 0 lose = 0 def jyanken(a,b): if a == b: return 0 elif a == 1 and b == 2: print('相手は...チョキ!') return 1 elif a == 1 and b == 3: print('相手は...パー!') return -1 elif a == 2 and b == 1: print('相手は...グー!') return -1 elif a == 2 and b == 3: print('相手は...パー!') return 1 elif a == 3 and b == 1: print('相手は...グー!') return 1 elif a == 3 and b == 2: print('相手は...チョキ!') return 1 else: print('1~3の数字を入力してね!もう一度!') def jyanken_win(c,d): if d == 0: print('相手は上を向いた!') elif d == 1: print('相手は右を向いた!') elif d == 2: print('相手は下を向いた!') elif d == 3: print('相手は左を向いた!') if c == d: return 1 else: print('あーあ') def jyanken_lose(c,d): if d == 0: print('相手は...上!') elif d == 1: print('相手は...右!') elif d == 2: print('相手は...下!') elif d == 3: print('相手は...左!') if c == d: return 1 else: print('よし!') print("あっちむいてほいゲーム開始!!") while True: aite_hand = random.randint(1, 3) my_hand = int(input("何を出そう? (グーは1、チョキは2、パーは3)\n")) jyanken_kekka = jyanken(my_hand,aite_hand) print() if jyanken_kekka == 1: print("じゃんけんに勝ちました!") my_dire = int(input("指をどっちに向けようか? (↑は0、→は1、↓は2、←は3)\n")) aite_dire = random.randint(0,3) janken_win_result = jyanken_win(my_dire,aite_dire) if janken_win_result == 1: print("あなたの勝ち!!!") win += 1 if win < 3: print("もう一度!") else: print("よって" + str(win) + "勝" +str(lose) +"敗であなたの勝ち!") break else: print("残念...はずれ...") elif jyanken_kekka == 0: print("あいこ!もう一度!") elif jyanken_kekka == -1: print("じゃんけんに負けた...") my_dire = int(input("どっちに向こう? (↑は0、→は1、↓は2、←は3) \n")) aite_dire = random.randint(0,3) janken_lose_result = jyanken_lose(my_dire,aite_dire) if janken_lose_result == 1: print("あなたの負け。。。") lose +=1 if lose < 3: print("もう一度!") else: print("よって、" + str(win) + "勝" +str(lose) +"敗であなたの負け。。。") break else: print("回避!")