Skip to content

Commit cb4b689

Browse files
committed
More sign stuff
1 parent 9f877f6 commit cb4b689

File tree

18 files changed

+136
-139
lines changed

18 files changed

+136
-139
lines changed

src/games/game.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,6 @@ void GamePlayerRep::MakeStrategy()
153153

154154
void GamePlayerRep::MakeReducedStrats(GameTreeNodeRep *n, GameTreeNodeRep *nn)
155155
{
156-
int i;
157156
GameTreeNodeRep *m, *mm;
158157

159158
if (!n->GetParent()) {
@@ -165,7 +164,7 @@ void GamePlayerRep::MakeReducedStrats(GameTreeNodeRep *n, GameTreeNodeRep *nn)
165164
if (n->m_infoset->flag == 0) {
166165
// we haven't visited this infoset before
167166
n->m_infoset->flag = 1;
168-
for (i = 1; i <= n->NumChildren(); i++) {
167+
for (size_t i = 1; i <= n->NumChildren(); i++) {
169168
GameTreeNodeRep *m = n->m_children[i];
170169
n->whichbranch = m;
171170
n->m_infoset->whichbranch = i;

src/games/game.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ class GameNodeRep : public GameObject {
345345

346346
virtual int GetNumber() const = 0;
347347

348-
virtual int NumChildren() const = 0;
348+
virtual size_t NumChildren() const = 0;
349349
virtual GameNode GetChild(int i) const = 0;
350350
virtual GameNode GetChild(const GameAction &) const = 0;
351351
virtual Array<GameNode> GetChildren() const = 0;
@@ -566,7 +566,7 @@ class GameRep : public BaseGameRep {
566566
/// Returns the root node of the game
567567
virtual GameNode GetRoot() const = 0;
568568
/// Returns the number of nodes in the game
569-
virtual int NumNodes() const = 0;
569+
virtual size_t NumNodes() const = 0;
570570
//@}
571571

572572
/// @name Modification

src/games/gameagg.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ class GameAGGRep : public GameRep {
112112
/// Returns the root node of the game
113113
GameNode GetRoot() const override { throw UndefinedException(); }
114114
/// Returns the number of nodes in the game
115-
int NumNodes() const override { throw UndefinedException(); }
115+
size_t NumNodes() const override { throw UndefinedException(); }
116116
//@}
117117

118118
/// @name General data access

src/games/gamebagg.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ class GameBAGGRep : public GameRep {
113113
/// Returns the root node of the game
114114
GameNode GetRoot() const override { throw UndefinedException(); }
115115
/// Returns the number of nodes in the game
116-
int NumNodes() const override { throw UndefinedException(); }
116+
size_t NumNodes() const override { throw UndefinedException(); }
117117
//@}
118118

119119
/// @name General data access

src/games/gametable.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ class GameTableRep : public GameExplicitRep {
8989
/// Returns the root node of the game
9090
GameNode GetRoot() const override { throw UndefinedException(); }
9191
/// Returns the number of nodes in the game
92-
int NumNodes() const override { throw UndefinedException(); }
92+
size_t NumNodes() const override { throw UndefinedException(); }
9393
//@}
9494

9595
/// @name Outcomes

src/games/gametree.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,7 @@ Rational SubtreeSum(const GameNode &p_node)
699699

700700
if (p_node->NumChildren() > 0) {
701701
sum = SubtreeSum(p_node->GetChild(1));
702-
for (int i = 2; i <= p_node->NumChildren(); i++) {
702+
for (size_t i = 2; i <= p_node->NumChildren(); i++) {
703703
if (SubtreeSum(p_node->GetChild(i)) != sum) {
704704
throw NotZeroSumException();
705705
}
@@ -1020,17 +1020,17 @@ void GameTreeRep::DeleteOutcome(const GameOutcome &p_outcome)
10201020
//------------------------------------------------------------------------
10211021

10221022
namespace {
1023-
int CountNodes(GameNode p_node)
1023+
size_t CountNodes(GameNode p_node)
10241024
{
1025-
int num = 1;
1026-
for (int i = 1; i <= p_node->NumChildren(); num += CountNodes(p_node->GetChild(i++)))
1025+
size_t num = 1;
1026+
for (size_t i = 1; i <= p_node->NumChildren(); num += CountNodes(p_node->GetChild(i++)))
10271027
;
10281028
return num;
10291029
}
10301030

10311031
} // end anonymous namespace
10321032

1033-
int GameTreeRep::NumNodes() const { return CountNodes(m_root); }
1033+
size_t GameTreeRep::NumNodes() const { return CountNodes(m_root); }
10341034

10351035
//------------------------------------------------------------------------
10361036
// GameTreeRep: Modification

src/games/gametree.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ class GameTreeNodeRep : public GameNodeRep {
162162
void SetLabel(const std::string &p_label) override { m_label = p_label; }
163163

164164
int GetNumber() const override { return m_number; }
165-
int NumChildren() const override { return m_children.size(); }
165+
size_t NumChildren() const override { return m_children.size(); }
166166
GameNode GetChild(int i) const override { return m_children[i]; }
167167
GameNode GetChild(const GameAction &p_action) const override
168168
{
@@ -265,7 +265,7 @@ class GameTreeRep : public GameExplicitRep {
265265
/// Returns the root node of the game
266266
GameNode GetRoot() const override { return m_root; }
267267
/// Returns the number of nodes in the game
268-
int NumNodes() const override;
268+
size_t NumNodes() const override;
269269
//@}
270270

271271
void DeleteOutcome(const GameOutcome &) override;

src/gui/dleditmove.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ gbtActionSheet::gbtActionSheet(wxWindow *p_parent, const Gambit::GameInfoset &p_
6060
SetColLabelValue(1, wxT("Probability"));
6161
}
6262

63-
for (int act = 1; act <= p_infoset->NumActions(); act++) {
63+
for (size_t act = 1; act <= p_infoset->NumActions(); act++) {
6464
SetCellValue(wxSheetCoords(act - 1, 0),
6565
wxString(p_infoset->GetAction(act)->GetLabel().c_str(), *wxConvCurrent));
6666
if (p_infoset->IsChanceInfoset()) {
@@ -214,7 +214,7 @@ void gbtEditMoveDialog::OnOK(wxCommandEvent &p_event)
214214
}
215215
Array<Number> probs = m_actionSheet->GetActionProbs();
216216
Rational sum(0);
217-
for (int act = 1; act <= m_infoset->NumActions(); act++) {
217+
for (size_t act = 1; act <= m_infoset->NumActions(); act++) {
218218
auto prob = static_cast<Rational>(probs[act]);
219219
if (prob < Gambit::Rational(0)) {
220220
wxMessageBox("Action probabilities must be nonnegative numbers.", "Error");

src/gui/dlefgreveal.cc

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
#include "gambit.h"
2929
#include "dlefgreveal.h"
3030

31+
using namespace Gambit;
32+
3133
//=========================================================================
3234
// gbtRevealMoveDialog: Member functions
3335
//=========================================================================
@@ -41,8 +43,8 @@ gbtRevealMoveDialog::gbtRevealMoveDialog(wxWindow *p_parent, gbtGameDocument *p_
4143

4244
auto *boxSizer = new wxBoxSizer(wxVERTICAL);
4345

44-
for (int pl = 1; pl <= m_doc->NumPlayers(); pl++) {
45-
const Gambit::GamePlayer player = m_doc->GetGame()->GetPlayer(pl);
46+
for (size_t pl = 1; pl <= m_doc->NumPlayers(); pl++) {
47+
auto player = m_doc->GetGame()->GetPlayer(pl);
4648
if (player->GetLabel().empty()) {
4749
m_players.push_back(
4850
new wxCheckBox(this, wxID_ANY, wxString(player->GetLabel().c_str(), *wxConvCurrent)));
@@ -71,11 +73,11 @@ gbtRevealMoveDialog::gbtRevealMoveDialog(wxWindow *p_parent, gbtGameDocument *p_
7173
CenterOnParent();
7274
}
7375

74-
Gambit::Array<Gambit::GamePlayer> gbtRevealMoveDialog::GetPlayers() const
76+
Array<GamePlayer> gbtRevealMoveDialog::GetPlayers() const
7577
{
76-
Gambit::Array<Gambit::GamePlayer> players;
78+
Array<GamePlayer> players;
7779

78-
for (int pl = 1; pl <= m_doc->NumPlayers(); pl++) {
80+
for (size_t pl = 1; pl <= m_doc->NumPlayers(); pl++) {
7981
if (m_players[pl]->GetValue()) {
8082
players.push_back(m_doc->GetGame()->GetPlayer(pl));
8183
}

src/gui/dlinsertmove.cc

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,13 @@ gbtInsertMoveDialog::gbtInsertMoveDialog(wxWindow *p_parent, gbtGameDocument *p_
3636
{
3737
m_playerItem = new wxChoice(this, wxID_ANY);
3838
m_playerItem->Append(_("Insert move for the chance player"));
39-
for (int pl = 1; pl <= m_doc->NumPlayers(); pl++) {
39+
for (const auto &player : m_doc->GetGame()->GetPlayers()) {
4040
wxString s = _("Insert move for ");
41-
const Gambit::GamePlayer player = m_doc->GetGame()->GetPlayer(pl);
4241
if (player->GetLabel() != "") {
4342
s += wxString(player->GetLabel().c_str(), *wxConvCurrent);
4443
}
4544
else {
46-
s += wxString::Format(_("player %d"), pl);
45+
s += wxString::Format(_("player %d"), player->GetNumber());
4746
}
4847
m_playerItem->Append(s);
4948
}
@@ -119,7 +118,7 @@ void gbtInsertMoveDialog::OnPlayer(wxCommandEvent &)
119118
if (playerNumber == 0) {
120119
player = m_doc->GetGame()->GetChance();
121120
}
122-
else if (playerNumber <= m_doc->NumPlayers()) {
121+
else if (playerNumber <= static_cast<int>(m_doc->NumPlayers())) {
123122
player = m_doc->GetGame()->GetPlayer(playerNumber);
124123
}
125124

@@ -189,7 +188,7 @@ Gambit::GamePlayer gbtInsertMoveDialog::GetPlayer() const
189188
if (playerNumber == 0) {
190189
return m_doc->GetGame()->GetChance();
191190
}
192-
else if (playerNumber <= m_doc->NumPlayers()) {
191+
else if (playerNumber <= static_cast<int>(m_doc->NumPlayers())) {
193192
return m_doc->GetGame()->GetPlayer(playerNumber);
194193
}
195194
else {
@@ -201,7 +200,7 @@ Gambit::GamePlayer gbtInsertMoveDialog::GetPlayer() const
201200

202201
Gambit::GameInfoset gbtInsertMoveDialog::GetInfoset() const
203202
{
204-
if (m_playerItem->GetSelection() <= m_doc->NumPlayers()) {
203+
if (m_playerItem->GetSelection() <= static_cast<int>(m_doc->NumPlayers())) {
205204
const Gambit::GamePlayer player = GetPlayer();
206205
const int infosetNumber = m_infosetItem->GetSelection();
207206

0 commit comments

Comments
 (0)