@@ -93,7 +93,7 @@ Rational TablePureStrategyProfileRep::GetPayoff(const GamePlayer &p_player) cons
93
93
{
94
94
GameOutcomeRep *outcome = dynamic_cast <GameTableRep &>(*m_nfg).m_results [m_index];
95
95
if (outcome) {
96
- return static_cast <Rational>( outcome->GetPayoff (p_player) );
96
+ return outcome->GetPayoff <Rational> (p_player);
97
97
}
98
98
else {
99
99
return Rational (0 );
@@ -102,13 +102,12 @@ Rational TablePureStrategyProfileRep::GetPayoff(const GamePlayer &p_player) cons
102
102
103
103
Rational TablePureStrategyProfileRep::GetStrategyValue (const GameStrategy &p_strategy) const
104
104
{
105
- int player = p_strategy->GetPlayer ()-> GetNumber ();
105
+ const auto & player = p_strategy->GetPlayer ();
106
106
GameOutcomeRep *outcome =
107
107
dynamic_cast <GameTableRep &>(*m_nfg)
108
- .m_results [m_index - m_profile.at (p_strategy->GetPlayer ())->m_offset +
109
- p_strategy->m_offset ];
108
+ .m_results [m_index - m_profile.at (player)->m_offset + p_strategy->m_offset ];
110
109
if (outcome) {
111
- return static_cast <Rational>( outcome->GetPayoff (player) );
110
+ return outcome->GetPayoff <Rational> (player);
112
111
}
113
112
else {
114
113
return Rational (0 );
@@ -164,7 +163,7 @@ T TableMixedStrategyProfileRep<T>::GetPayoff(int pl, int index, int current) con
164
163
auto &g = dynamic_cast <GameTableRep &>(*game);
165
164
GameOutcomeRep *outcome = g.m_results [index ];
166
165
if (outcome) {
167
- return static_cast <T>(outcome-> GetPayoff (pl));
166
+ return outcome-> GetPayoff <T>(this -> m_support . GetGame ()-> GetPlayer (pl));
168
167
}
169
168
else {
170
169
return T (0 );
@@ -197,7 +196,7 @@ void TableMixedStrategyProfileRep<T>::GetPayoffDeriv(int pl, int const_pl, int c
197
196
auto &g = dynamic_cast <GameTableRep &>(*game);
198
197
GameOutcomeRep *outcome = g.m_results [index ];
199
198
if (outcome) {
200
- value += prob * static_cast <T>(outcome-> GetPayoff (pl));
199
+ value += prob * outcome-> GetPayoff <T>(this -> m_support . GetGame ()-> GetPlayer (pl));
201
200
}
202
201
}
203
202
else {
@@ -230,7 +229,7 @@ void TableMixedStrategyProfileRep<T>::GetPayoffDeriv(int pl, int const_pl1, int
230
229
auto &g = dynamic_cast <GameTableRep &>(*game);
231
230
GameOutcomeRep *outcome = g.m_results [index ];
232
231
if (outcome) {
233
- value += prob * static_cast <T>(outcome-> GetPayoff (pl));
232
+ value += prob * outcome-> GetPayoff <T>(this -> m_support . GetGame ()-> GetPlayer (pl));
234
233
}
235
234
}
236
235
else {
@@ -371,7 +370,7 @@ void GameTableRep::WriteNfgFile(std::ostream &p_file) const
371
370
p_file << " { " + QuoteString (outcome->GetLabel ()) << ' '
372
371
<< FormatList (
373
372
players,
374
- [outcome](const GamePlayer &p) { return std::string (outcome-> GetPayoff (p) ); },
373
+ [outcome](const GamePlayer &p) { return outcome-> GetPayoff < std::string>(p ); },
375
374
true , false )
376
375
<< " }" << std::endl;
377
376
}
@@ -393,7 +392,7 @@ GamePlayer GameTableRep::NewPlayer()
393
392
auto player = new GamePlayerRep (this , m_players.size () + 1 , 1 );
394
393
m_players.push_back (player);
395
394
for (auto outcome : m_outcomes) {
396
- outcome->m_payoffs . push_back ( Number () );
395
+ outcome->m_payoffs [player] = Number ();
397
396
}
398
397
return player;
399
398
}
0 commit comments