Skip to content

Commit 07b9ee7

Browse files
committed
Revert unrelated changes.
1 parent 1dabf1e commit 07b9ee7

6 files changed

Lines changed: 9 additions & 49 deletions

File tree

.github/workflows/python.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,4 +107,4 @@ jobs:
107107
run: |
108108
python -m pip install -v .
109109
- name: Run tests
110-
run: pytest -vv
110+
run: pytest

src/games/gameobject.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ template <class T> class GameObjectPtr {
135135
bool operator<(const GameObjectPtr<T> &r) const { return (m_rep < r.m_rep); }
136136

137137
operator bool() const noexcept { return m_rep != nullptr; }
138-
operator std::shared_ptr<T>() const { return get_shared(); }
138+
operator std::shared_ptr<T>() const { return m_rep; }
139139
};
140140

141141
template <class P, class T> class ElementCollection {

src/games/gametable.cc

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
//
2222

2323
#include <iostream>
24-
#include <memory>
2524

2625
#include "gambit.h"
2726
#include "gametable.h"
@@ -67,7 +66,7 @@ std::shared_ptr<PureStrategyProfileRep> TablePureStrategyProfileRep::Copy() cons
6766

6867
Game NewTable(const std::vector<int> &p_dim, bool p_sparseOutcomes /*= false*/)
6968
{
70-
return GameTableRep::Create(p_dim, p_sparseOutcomes);
69+
return std::make_shared<GameTableRep>(p_dim, p_sparseOutcomes);
7170
}
7271

7372
//------------------------------------------------------------------------
@@ -264,10 +263,6 @@ template class TableMixedStrategyProfileRep<Rational>;
264263

265264
GameTableRep::GameTableRep(const std::vector<int> &dim, bool p_sparseOutcomes /* = false */)
266265
: m_results(std::accumulate(dim.begin(), dim.end(), 1, std::multiplies<>()))
267-
{
268-
}
269-
270-
void GameTableRep::Initialize(const std::vector<int> &dim, bool p_sparseOutcomes /* = false */)
271266
{
272267
for (const auto &nstrat : dim) {
273268
m_players.push_back(std::make_shared<GamePlayerRep>(this, m_players.size() + 1, nstrat));
@@ -292,15 +287,6 @@ void GameTableRep::Initialize(const std::vector<int> &dim, bool p_sparseOutcomes
292287
}
293288
}
294289

295-
std::shared_ptr<GameTableRep> GameTableRep::Create(const std::vector<int> &dim,
296-
bool sparseOutcomes)
297-
{
298-
auto rep = std::shared_ptr<GameTableRep>(new GameTableRep(dim, sparseOutcomes));
299-
rep->Initialize(dim, sparseOutcomes);
300-
301-
return rep;
302-
}
303-
304290
Game GameTableRep::Copy() const
305291
{
306292
std::ostringstream os;

src/games/gametable.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,12 @@ class GameTableRep : public GameExplicitRep {
4444
void RebuildTable();
4545
//@}
4646

47-
explicit GameTableRep(const std::vector<int> &p_dim, bool p_sparseOutcomes = false);
48-
void Initialize(const std::vector<int> &dim, bool p_sparseOutcomes);
49-
5047
public:
5148
/// @name Lifecycle
5249
//@{
5350
/// Construct a new table game with the given dimension
5451
/// If p_sparseOutcomes = true, outcomes for all contingencies are left null
55-
static std::shared_ptr<GameTableRep> Create(const std::vector<int> &dim,
56-
bool sparseOutcomes = false);
52+
explicit GameTableRep(const std::vector<int> &p_dim, bool p_sparseOutcomes = false);
5753
Game Copy() const override;
5854
//@}
5955

src/games/gametree.cc

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -701,28 +701,10 @@ GameInfoset GameTreeRep::InsertMove(GameNode p_node, GameInfoset p_infoset)
701701
// GameTreeRep: Lifecycle
702702
//------------------------------------------------------------------------
703703

704-
GameTreeRep::GameTreeRep() = default;
705-
706-
void GameTreeRep::Initialize()
707-
{
708-
auto self = shared_from_this();
709-
710-
// Now construct children using the VALID GameTreeRep*
711-
m_root = std::make_shared<GameNodeRep>(self.get(), nullptr);
712-
m_chance = std::make_shared<GamePlayerRep>(self.get(), 0);
713-
714-
// If GameNodeRep creates children of its own, same pattern applies
715-
}
716-
717-
std::shared_ptr<GameTreeRep> GameTreeRep::Create()
704+
GameTreeRep::GameTreeRep()
705+
: m_root(std::make_shared<GameNodeRep>(this, nullptr)),
706+
m_chance(std::make_shared<GamePlayerRep>(this, 0))
718707
{
719-
// Construct object under shared_ptr CONTROL BLOCK
720-
auto rep = std::shared_ptr<GameTreeRep>(new GameTreeRep());
721-
722-
// Now safe to construct children because shared_from_this works
723-
rep->Initialize();
724-
725-
return rep;
726708
}
727709

728710
GameTreeRep::~GameTreeRep()
@@ -739,7 +721,7 @@ Game GameTreeRep::Copy() const
739721
return ReadGame(is);
740722
}
741723

742-
Game NewTree() { return GameTreeRep::Create(); }
724+
Game NewTree() { return std::make_shared<GameTreeRep>(); }
743725

744726
//------------------------------------------------------------------------
745727
// GameTreeRep: General data access

src/games/gametree.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,10 @@ class GameTreeRep : public GameExplicitRep {
6868
void CopySubtree(GameNodeRep *, GameNodeRep *, GameNodeRep *);
6969
//@}
7070

71-
GameTreeRep();
72-
void Initialize();
73-
7471
public:
7572
/// @name Lifecycle
7673
//@{
77-
78-
static std::shared_ptr<GameTreeRep> Create();
74+
GameTreeRep();
7975
~GameTreeRep() override;
8076
Game Copy() const override;
8177
//@}

0 commit comments

Comments
 (0)