Last active
December 18, 2015 21:09
-
-
Save alea12/5845519 to your computer and use it in GitHub Desktop.
囚人のジレンマ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# input: | |
# strategy_i - strategy of player 1, 2. | |
# output: | |
# payoff_i - payoff rewarded to player 1, 2. | |
def prisoner (strategy_1, strategy_2) | |
if strategy_1 == "m" | |
if strategy_2 == "m" | |
payoff_1 = -1 | |
payoff_2 = -1 | |
elsif strategy_2 == "f" | |
payoff_1 = -9 | |
payoff_2 = -0 | |
end | |
elsif strategy_1 == "f" | |
if strategy_2 == "m" | |
payoff_1 = 0 | |
payoff_2 = -9 | |
elsif strategy_2 == "f" | |
payoff_1 = -6 | |
payoff_2 = -6 | |
end | |
end | |
return payoff_1, payoff_2 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment