I am building a small simulation of Rock, Paper and Scissors, I have a payoff function that returns a tuple of numbers given two actions
def payoff(act1, act2):
if act1, act2 == Action.ROCK, Action.PAPER:
return -1, 1
elif act1, act2 == Action.PAPER, Action.ROCK:
return 1, -1
elif act1, act2 == Action.PAPER, Action.SCISSORS:
return -1, 1
elif act1, act2 == Action.SCISSORS, Action.PAPER:
return 1, -1
elif act1, act2 == Action.SCISSORS, Action.ROCK:
return -1, 1
elif act1, act2 == Action.ROCK, Action.SCISSORS:
return 1, -1
else :
return 0, 0
I sample two actions at random when given as parameters the equality always fails.
action1 = random.sample([Action.ROCK,Action.PAPER,Action.SCISSORS],1)
action2 = random.sample([Action.ROCK,Action.PAPER,Action.SCISSORS],1)
# always returns (0,0)
payoff(action1,action2)
I am not sure if am doing the equality check properly, as you may notice I construct tuples on the fly using (act1,act2)