|
| 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