@@ -93,7 +93,7 @@ Rational TablePureStrategyProfileRep::GetPayoff(const GamePlayer &p_player) cons
9393{
9494 GameOutcomeRep *outcome = dynamic_cast <GameTableRep &>(*m_nfg).m_results [m_index];
9595 if (outcome) {
96- return static_cast <Rational>( outcome->GetPayoff (p_player) );
96+ return outcome->GetPayoff <Rational> (p_player);
9797 }
9898 else {
9999 return Rational (0 );
@@ -102,13 +102,12 @@ Rational TablePureStrategyProfileRep::GetPayoff(const GamePlayer &p_player) cons
102102
103103Rational TablePureStrategyProfileRep::GetStrategyValue (const GameStrategy &p_strategy) const
104104{
105- int player = p_strategy->GetPlayer ()-> GetNumber ();
105+ const auto & player = p_strategy->GetPlayer ();
106106 GameOutcomeRep *outcome =
107107 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 ];
110109 if (outcome) {
111- return static_cast <Rational>( outcome->GetPayoff (player) );
110+ return outcome->GetPayoff <Rational> (player);
112111 }
113112 else {
114113 return Rational (0 );
@@ -164,7 +163,7 @@ T TableMixedStrategyProfileRep<T>::GetPayoff(int pl, int index, int current) con
164163 auto &g = dynamic_cast <GameTableRep &>(*game);
165164 GameOutcomeRep *outcome = g.m_results [index];
166165 if (outcome) {
167- return static_cast <T>(outcome-> GetPayoff (pl));
166+ return outcome-> GetPayoff <T>(this -> m_support . GetGame ()-> GetPlayer (pl));
168167 }
169168 else {
170169 return T (0 );
@@ -197,7 +196,7 @@ void TableMixedStrategyProfileRep<T>::GetPayoffDeriv(int pl, int const_pl, int c
197196 auto &g = dynamic_cast <GameTableRep &>(*game);
198197 GameOutcomeRep *outcome = g.m_results [index];
199198 if (outcome) {
200- value += prob * static_cast <T>(outcome-> GetPayoff (pl));
199+ value += prob * outcome-> GetPayoff <T>(this -> m_support . GetGame ()-> GetPlayer (pl));
201200 }
202201 }
203202 else {
@@ -230,7 +229,7 @@ void TableMixedStrategyProfileRep<T>::GetPayoffDeriv(int pl, int const_pl1, int
230229 auto &g = dynamic_cast <GameTableRep &>(*game);
231230 GameOutcomeRep *outcome = g.m_results [index];
232231 if (outcome) {
233- value += prob * static_cast <T>(outcome-> GetPayoff (pl));
232+ value += prob * outcome-> GetPayoff <T>(this -> m_support . GetGame ()-> GetPlayer (pl));
234233 }
235234 }
236235 else {
@@ -371,7 +370,7 @@ void GameTableRep::WriteNfgFile(std::ostream &p_file) const
371370 p_file << " { " + QuoteString (outcome->GetLabel ()) << ' '
372371 << FormatList (
373372 players,
374- [outcome](const GamePlayer &p) { return std::string (outcome-> GetPayoff (p) ); },
373+ [outcome](const GamePlayer &p) { return outcome-> GetPayoff < std::string>(p ); },
375374 true , false )
376375 << " }" << std::endl;
377376 }
@@ -393,7 +392,7 @@ GamePlayer GameTableRep::NewPlayer()
393392 auto player = new GamePlayerRep (this , m_players.size () + 1 , 1 );
394393 m_players.push_back (player);
395394 for (auto outcome : m_outcomes) {
396- outcome->m_payoffs . push_back ( Number () );
395+ outcome->m_payoffs [player] = Number ();
397396 }
398397 return player;
399398}
0 commit comments