15 lines
534 B
Python
15 lines
534 B
Python
|
def wyplata( player, strategy_one, strategy_two, pay_one, pay_two ):
|
||
|
|
||
|
if( len(strategy_one) != len(pay_one) ):
|
||
|
raise Exception("Wrong arguments")
|
||
|
if( sum(strategy_one) != 1 or sum(strategy_two) != 1 ):
|
||
|
raise Exception("Wrong arguments")
|
||
|
|
||
|
value = 0
|
||
|
for i in range(0,len(strategy_one)):
|
||
|
for k in range(0, len(strategy_two)):
|
||
|
value += strategy_one[i]*strategy_two[k] * (pay_one[i][k] if player == 1 else pay_two[i][k])
|
||
|
return value
|
||
|
|
||
|
#print(wyplata(2, [1/2,1/2,0], [1/4,3/4], [[0,0],[2,-1],[-1,2]], [[2,2],[0,1],[1,0]] ))
|