2017-10-23 1 views
-1

바위 종이 가위 코드. 임의의 하나를 선택하고 사용자 inputed 선택에 넣어 가정, 때로는 작동하지만 그것은 변경 동일해야 같은 가능성에 다른 사람은 당신은 결코 따기되지엘프가 엉망이 된 프로그램

import random  
def one_game(): 
    score_bot = 0 
    score_player = 0 
    a = ["rock", "paper", "scissors"] 
    UI = raw_input('(enter your choice rock, paper, or scissors)') 
    print(random.choice(a)) 
    if (random.choice(a)) == (UI): 
     print ('Tie') 
     score_bot+1 
     score_player+1 
    elif 'rock' in (UI) and 'scissors' in (random.choice(a)): 
     print ('You win!') 
     score_player+1 
    elif 'rock' in (UI) and 'paper' in (random.choice(a)): 
     print ('You lose!') 
     score_bot+1 
    elif 'paper' in (UI) and 'scissors' in (random.choice(a)): 
     print ('You lose!') 
     score_bot+1   
    elif 'paper' in (UI) and 'rock' in (random.choice(a)): 
     print ('You win!') 
     score_player+1 
    elif 'scissors' in (UI) and 'rock' in (random.choice(a)): 
     print ('You lose!') 
     score_bot+1 
    elif 'scissors' in (UI) and 'paper' in (random.choice(a)): 
     print ('You win!') 
     score_player+1 
     print (score_player) 
     print (score_bot) 
     if (score_bot) > (score_player): 
      print ('bot wins!') 
     elif (score_bot) < (score_player): 
      print ('Player wins!') 

the issue

+0

와 모든 미래 random.choice(a)를 대체? 너는 무엇을 기대하고 있니? –

답변

3

성과 컴퓨터에 대한 임의의 선택. 대신 모든 if 문에서 새로운 무작위를 계산합니다.

시도 :

computer_choice = random.choice(a) 

그리고 당신이 점점 오류가 무엇인지 computer_choice

관련 문제