22 #ifndef _SGRISKSHARING_3PLAYER_HPP
23 #define _SGRISKSHARING_3PLAYER_HPP
33 vector<vector<int> > E;
36 vector<int> numActions_total;
37 vector< vector<int> > transferList;;
43 numEndowments(_numEndowments),
46 numActions_total(_numEndowments,1),
49 vector< vector<int> > (_numEndowments,vector<int>(3,1)))
58 for (
int e0 = 0; e0 < numEndowments; e0++)
60 for (
int e1 = 0; e1 < numEndowments-e0; e1++)
62 vector<int>newEndowments(3,0);
63 newEndowments[0] = e0;
64 newEndowments[1] = e1;
65 newEndowments[2] = numEndowments-1 -e0-e1;
66 E.push_back(newEndowments);
73 eIncr = 1.0/(numEndowments-1.0);
74 cIncr = 1.0/( (numEndowments-1)*c2e );
78 vector<int> transferStartPositions(numEndowments+1,0);
82 for (
int e = 0; e < numEndowments; e++)
84 transferStartPositions[e] = transferList.size();
86 for (
int t0 = 0; t0 < e*c2e+1; t0++)
88 for (
int t1 = 0; t1 < e*c2e+1-t0; t1++)
90 vector<int> newTransfers (2,0);
94 transferList.push_back(newTransfers);
98 transferStartPositions.back() = transferList.size();
101 numActions_total = vector< int > (
numStates,1);
108 numActions[s][p] = transferStartPositions[E[s][p]+1];
122 netTransfers[p] -= transferList[actions[p]][0];
123 netTransfers[p] -= transferList[actions[p]][1];
124 netTransfers[(p+1)%
numPlayers] += transferList[actions[p]][0];
125 netTransfers[(p+2)%
numPlayers] += transferList[actions[p]][1];
130 payoffs[p] = sqrt(E[state][p]*eIncr + netTransfers[p]*cIncr);
135 virtual double probability(
int e,
const vector<int> & actions,
int ep)
const
145 int numReceivingXfers = 0;
146 int numSendingXfers = 0;
152 numSendingXfers += actions[p]>0;
153 if (transferList[actions[p]][0]>0)
155 if (transferList[actions[p]][1]>0)
160 numReceivingXfers += receives[p];
162 return (numReceivingXfers <= 1
163 || (numReceivingXfers == 2 && numSendingXfers == 1));