Skip to content

Commit 53c02bd

Browse files
Changed LP so that minpay is only subtracted from terminal outcomes
1 parent 3dbffa2 commit 53c02bd

3 files changed

Lines changed: 51 additions & 1 deletion

File tree

src/games/gameseq.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,13 @@ void GameSequenceForm::FillTableau(const GameNode &n, const Rational &prob,
7070
std::map<GamePlayer, GameSequence> &p_currentSequences)
7171
{
7272
if (n->GetOutcome()) {
73-
IsOutcome(p_currentSequences) = 1;
7473
for (auto player : m_support.GetGame()->GetPlayers()) {
7574
GetPayoffEntry(p_currentSequences, player) +=
7675
prob * n->GetOutcome()->GetPayoff<Rational>(player);
7776
}
7877
}
7978
if (!n->GetInfoset()) {
79+
IsOutcome(p_currentSequences) = 1;
8080
return;
8181
}
8282
if (n->GetPlayer()->IsChance()) {

src/solvers/lp/lp.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ template <class T> void GameData<T>::FillTableau(Matrix<T> &A, const Game &p_gam
9090
if (p_game->IsOutcome(profile)) {
9191
A(row, col) = p_game->GetPayoff(profile, player1) - minpay;
9292
}
93+
else {
94+
A(row, col) = p_game->GetPayoff(profile, player1);
95+
}
9396
}
9497
}
9598
}

test_internal_outcomes.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import pygambit as gbt
2+
3+
solver = gbt.nash.lp_solve
4+
5+
g = gbt.Game.new_tree(players=["1", "2"], title="2 player perfect info win lose")
6+
g.append_move(g.root, "2", ["a", "b"])
7+
g.append_move(g.root.children[0], "1", ["L", "R"])
8+
g.append_move(g.root.children[1], "1", ["L", "R"])
9+
g.append_move(g.root.children[0].children[0], "2", ["l", "r"])
10+
g.set_outcome(
11+
g.root.children[0].children[0].children[0], g.add_outcome([1, -1], label="aLl")
12+
)
13+
g.set_outcome(
14+
g.root.children[0].children[0].children[1], g.add_outcome([-1, 1], label="aLr")
15+
)
16+
g.set_outcome(g.root.children[0].children[1], g.add_outcome([1, -1], label="aR"))
17+
g.set_outcome(g.root.children[1].children[0], g.add_outcome([1, -1], label="bL"))
18+
g.set_outcome(g.root.children[1].children[1], g.add_outcome([-1, 1], label="bR"))
19+
20+
print("blah")
21+
22+
equilibria = solver(g).equilibria
23+
eqm = equilibria[0]
24+
print(eqm["1"])
25+
print(eqm["2"])
26+
27+
28+
g = gbt.Game.new_tree(players=["1", "2"], title="2 player perfect info win lose")
29+
g.append_move(g.root, "2", ["a", "b"])
30+
g.append_move(g.root.children[0], "1", ["L", "R"])
31+
g.append_move(g.root.children[1], "1", ["L", "R"])
32+
g.append_move(g.root.children[0].children[0], "2", ["l", "r"])
33+
g.set_outcome(g.root.children[0], g.add_outcome([-10, 10], label="a"))
34+
g.set_outcome(
35+
g.root.children[0].children[0].children[0], g.add_outcome([11, -11], label="aLl")
36+
)
37+
g.set_outcome(
38+
g.root.children[0].children[0].children[1], g.add_outcome([9, -9], label="aLr")
39+
)
40+
g.set_outcome(g.root.children[0].children[1], g.add_outcome([11, -11], label="aR"))
41+
g.set_outcome(g.root.children[1].children[0], g.add_outcome([1, -1], label="bL"))
42+
g.set_outcome(g.root.children[1].children[1], g.add_outcome([-1, 1], label="bR"))
43+
44+
equilibria = solver(g).equilibria
45+
eqm = equilibria[0]
46+
print(eqm["1"])
47+
print(eqm["2"])

0 commit comments

Comments
 (0)