File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -184,15 +184,16 @@ GameRep::~GameRep()
184184
185185void GameRep::IndexStrategies () const
186186{
187- long offset = 1L ;
188- for (auto player : m_players) {
189- int st = 1 ;
190- for (auto strategy : player->m_strategies ) {
191- strategy->m_number = st;
192- strategy->m_offset = (st - 1 ) * offset;
193- st++;
187+ long stride = 1L ;
188+ for (const auto player : m_players) {
189+ player->m_stride = stride;
190+ int digit = 0 ;
191+ for (const auto strategy : player->m_strategies ) {
192+ strategy->m_number = digit + 1 ;
193+ strategy->m_offset = digit * stride;
194+ ++digit;
194195 }
195- offset *= player->m_strategies .size ();
196+ stride *= player->m_strategies .size ();
196197 }
197198}
198199
Original file line number Diff line number Diff line change @@ -363,6 +363,7 @@ class GamePlayerRep : public std::enable_shared_from_this<GamePlayerRep> {
363363 friend class GameInfosetRep ;
364364 friend class GameNodeRep ;
365365 friend class StrategySupportProfile ;
366+ friend class PureStrategyProfileRep ;
366367 template <class T > friend class MixedBehaviorProfile ;
367368 template <class T > friend class MixedStrategyProfile ;
368369
@@ -378,6 +379,8 @@ class GamePlayerRep : public std::enable_shared_from_this<GamePlayerRep> {
378379 bool m_valid{true };
379380 GameRep *m_game;
380381 int m_number;
382+ // The stride of the player into the set of pure strategy profiles
383+ long m_stride{0 };
381384 std::string m_label;
382385 std::vector<std::shared_ptr<GameInfosetRep>> m_infosets;
383386 std::vector<std::shared_ptr<GameStrategyRep>> m_strategies;
Original file line number Diff line number Diff line change @@ -61,9 +61,12 @@ class PureStrategyProfileRep {
6161 const Game &GetGame () const { return m_nfg; }
6262
6363 // / Get the strategy played by the player
64- const GameStrategy & GetStrategy (const GamePlayer &p_player) const
64+ GameStrategy GetStrategy (const GamePlayer &p_player) const
6565 {
66- return m_profile.at (p_player);
66+ const long stride = p_player->m_stride ;
67+ const long radix = p_player->m_strategies .size ();
68+ const long digit = (m_index / stride) % radix;
69+ return p_player->m_strategies [digit];
6770 }
6871
6972 // / Set the strategy for a player
You can’t perform that action at this time.
0 commit comments