Skip to content

Commit 36ccf6a

Browse files
pushed payoffs to terminal nodes in sequence form object
1 parent 7537624 commit 36ccf6a

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

src/games/gameseq.cc

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,23 +67,28 @@ void GameSequenceForm::BuildSequences()
6767
}
6868

6969
void GameSequenceForm::FillTableau(const GameNode &n, const Rational &prob,
70-
std::map<GamePlayer, GameSequence> &p_currentSequences)
70+
std::map<GamePlayer, GameSequence> &p_currentSequences,
71+
std::map<GamePlayer, Rational> p_cumPayoff)
7172
{
7273
if (n->GetOutcome()) {
7374
for (auto player : m_support.GetGame()->GetPlayers()) {
74-
GetPayoffEntry(p_currentSequences, player) +=
75-
prob * n->GetOutcome()->GetPayoff<Rational>(player);
75+
p_cumPayoff[player] += n->GetOutcome()->GetPayoff<Rational>(player);
76+
// GetPayoffEntry(p_currentSequences, player) +=
77+
// prob * n->GetOutcome()->GetPayoff<Rational>(player);
7678
}
7779
}
7880
if (!n->GetInfoset()) {
7981
GetTerminalProb(p_currentSequences) += prob;
82+
for (auto player : m_support.GetGame()->GetPlayers()) {
83+
GetPayoffEntry(p_currentSequences, player) += prob * p_cumPayoff[player];
84+
}
8085
return;
8186
}
8287
if (n->GetPlayer()->IsChance()) {
8388
for (auto action : n->GetInfoset()->GetActions()) {
8489
FillTableau(n->GetChild(action),
8590
prob * static_cast<Rational>(n->GetInfoset()->GetActionProb(action)),
86-
p_currentSequences);
91+
p_currentSequences, p_cumPayoff);
8792
}
8893
}
8994
else {
@@ -92,7 +97,7 @@ void GameSequenceForm::FillTableau(const GameNode &n, const Rational &prob,
9297
for (auto action : m_support.GetActions(n->GetInfoset())) {
9398
m_constraints[{n->GetInfoset(), action}] = -1;
9499
p_currentSequences[n->GetPlayer()] = m_correspondence.at(action);
95-
FillTableau(n->GetChild(action), prob, p_currentSequences);
100+
FillTableau(n->GetChild(action), prob, p_currentSequences, p_cumPayoff);
96101
}
97102
p_currentSequences[n->GetPlayer()] = tmp_sequence;
98103
}
@@ -108,10 +113,12 @@ void GameSequenceForm::FillTableau()
108113
m_terminalProb = NDArray<Rational>(dim, dim.size());
109114

110115
std::map<GamePlayer, GameSequence> currentSequence;
116+
std::map<GamePlayer, Rational> cumPayoff;
111117
for (auto player : GetPlayers()) {
112118
currentSequence[player] = m_sequences[player].front();
119+
cumPayoff[player] = Rational(0);
113120
}
114-
FillTableau(m_support.GetGame()->GetRoot(), Rational(1), currentSequence);
121+
FillTableau(m_support.GetGame()->GetRoot(), Rational(1), currentSequence, cumPayoff);
115122
}
116123

117124
} // end namespace Gambit

src/games/gameseq.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ class GameSequenceForm {
4444
void BuildSequences();
4545
void BuildSequences(const GameNode &, std::map<GamePlayer, GameSequence> &);
4646
void FillTableau();
47-
void FillTableau(const GameNode &, const Rational &, std::map<GamePlayer, GameSequence> &);
47+
void FillTableau(const GameNode &, const Rational &, std::map<GamePlayer, GameSequence> &,
48+
std::map<GamePlayer, Rational>);
4849

4950
Array<int> ProfileToIndex(const std::map<GamePlayer, GameSequence> &p_profile) const
5051
{

0 commit comments

Comments
 (0)