0
import random
def move():
myScore = 0
theirScore = 0
Options=['b','c']
myChoice=random.choice(Options)
theirChoice=random.choice(Options)
if myChoice == 'b' and theirChoice == 'b':
myScore = myScore-250
theirScore = theirScore-250
if myChoice == 'b' and theirChoice == 'c':
myScore = myScore + 100
theirScore = theirScore - 500
if myChoice == 'c' and theirChoice == 'b':
myScore = myScore - 500
theirScore = theirScore + 100
if myChoice == 'c' and theirChoice == 'c':
myScore = myScore + 0
theirScore = theirScore + 0
return myChoice
return myScore
return theirChoice
return theirScore
위 코드는 Python으로 작성한 코드입니다. 무작위로 'c'와 'b'라는 문자열로 표시된 결탁이나 배신을 선택하고 이에 따라 점수를 변경 한 다음 선택한 항목과 새 점수를 반환합니다. 입력이없는 일회용 프로그램입니다. 다음은 내 프로그램에서 발생하는 것입니다 :Prisoner 's Dilemma를 무작위로 실행하지만 실행되지 않습니다.
In: move
Out: '<function __main__.move>'
나는 왜 내가이 출력을 얻는 지 잘 모르겠다. 감사합니다. 감사합니다.
1) 당신은 ('이동 호출되지)'2) 여러 개의 return 문을 사용할 수는 없지만 한 줄에 여러 값을 반환 할 수 있습니다. –
함수를 호출하지 않았습니다. – user2357112
나는()을 잊어 버렸고, 반품을 고치겠다. 고마워. –