Skip to content

Commit e0c405d

Browse files
Add unique IDs to markdown and code cells in OpenSpiel tutorial notebook
1 parent 78ca12f commit e0c405d

1 file changed

Lines changed: 46 additions & 19 deletions

File tree

doc/tutorials/interoperability_tutorials/openspiel.ipynb

Lines changed: 46 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"cells": [
33
{
44
"cell_type": "markdown",
5+
"id": "fcb19ba2",
56
"metadata": {},
67
"source": [
78
"# Using Gambit with OpenSpiel\n",
@@ -26,23 +27,22 @@
2627
},
2728
{
2829
"cell_type": "code",
29-
"execution_count": 1,
30+
"execution_count": null,
3031
"id": "ebb78322",
3132
"metadata": {},
3233
"outputs": [],
3334
"source": [
3435
"from io import StringIO\n",
35-
"import numpy as np\n",
36-
"import matplotlib.pyplot as plt\n",
3736
"\n",
37+
"import matplotlib.pyplot as plt\n",
38+
"import numpy as np\n",
39+
"import pyspiel\n",
3840
"from open_spiel.python import rl_environment\n",
3941
"from open_spiel.python.algorithms import tabular_qlearner\n",
4042
"from open_spiel.python.algorithms.gambit import export_gambit\n",
4143
"from open_spiel.python.egt import dynamics\n",
4244
"from open_spiel.python.egt.utils import game_payoffs_array\n",
4345
"\n",
44-
"import pyspiel\n",
45-
"\n",
4646
"import pygambit as gbt"
4747
]
4848
},
@@ -89,6 +89,7 @@
8989
{
9090
"cell_type": "code",
9191
"execution_count": 3,
92+
"id": "1d51af0a",
9293
"metadata": {},
9394
"outputs": [],
9495
"source": [
@@ -351,7 +352,7 @@
351352
},
352353
{
353354
"cell_type": "code",
354-
"execution_count": 11,
355+
"execution_count": null,
355356
"id": "b9a352c5",
356357
"metadata": {},
357358
"outputs": [
@@ -379,7 +380,10 @@
379380
" paper_proportions.append(x[1])\n",
380381
" scissors_proportions.append(x[2])\n",
381382
" if plot_average_strategy:\n",
382-
" y.append([np.mean(rock_proportions), np.mean(paper_proportions), np.mean(scissors_proportions)])\n",
383+
" y.append([np.mean(rock_proportions),\n",
384+
" np.mean(paper_proportions),\n",
385+
" np.mean(scissors_proportions)\n",
386+
" ])\n",
383387
" else:\n",
384388
" y.append(x.copy())\n",
385389
" y = np.array(y)\n",
@@ -640,6 +644,7 @@
640644
},
641645
{
642646
"cell_type": "markdown",
647+
"id": "9926fb07",
643648
"metadata": {},
644649
"source": [
645650
"<!-- ## Extensive-form example: Silly1111 Poker -->\n",
@@ -721,7 +726,7 @@
721726
},
722727
{
723728
"cell_type": "code",
724-
"execution_count": 21,
729+
"execution_count": null,
725730
"id": "1ec19b1c",
726731
"metadata": {},
727732
"outputs": [
@@ -740,7 +745,7 @@
740745
}
741746
],
742747
"source": [
743-
"eqm['Pl0']"
748+
"eqm[\"Pl0\"]"
744749
]
745750
},
746751
{
@@ -786,7 +791,7 @@
786791
},
787792
{
788793
"cell_type": "code",
789-
"execution_count": 23,
794+
"execution_count": null,
790795
"id": "8528e1bd",
791796
"metadata": {},
792797
"outputs": [
@@ -805,7 +810,7 @@
805810
}
806811
],
807812
"source": [
808-
"eqm['Pl1']"
813+
"eqm[\"Pl1\"]"
809814
]
810815
},
811816
{
@@ -983,7 +988,7 @@
983988
},
984989
{
985990
"cell_type": "code",
986-
"execution_count": 47,
991+
"execution_count": null,
987992
"id": "77dc34c8",
988993
"metadata": {},
989994
"outputs": [],
@@ -1007,7 +1012,10 @@
10071012
" )\n",
10081013
"\n",
10091014
"gbt_one_card_poker.append_move(\n",
1010-
" [gbt_one_card_poker.root.children[\"King\"].children[\"Bet\"], gbt_one_card_poker.root.children[\"Queen\"].children[\"Bet\"]],\n",
1015+
" [\n",
1016+
" gbt_one_card_poker.root.children[\"King\"].children[\"Bet\"],\n",
1017+
" gbt_one_card_poker.root.children[\"Queen\"].children[\"Bet\"]\n",
1018+
" ],\n",
10111019
" player=\"Bob\",\n",
10121020
" actions=[\"Call\", \"Fold\"]\n",
10131021
")\n",
@@ -1018,17 +1026,36 @@
10181026
"lose = gbt_one_card_poker.add_outcome([-1, 1], label=\"Lose\")\n",
10191027
"\n",
10201028
"# Alice folds, Bob wins small\n",
1021-
"gbt_one_card_poker.set_outcome(gbt_one_card_poker.root.children[\"King\"].children[\"Fold\"], lose)\n",
1022-
"gbt_one_card_poker.set_outcome(gbt_one_card_poker.root.children[\"Queen\"].children[\"Fold\"], lose)\n",
1029+
"gbt_one_card_poker.set_outcome(\n",
1030+
" gbt_one_card_poker.root.children[\"King\"].children[\"Fold\"],\n",
1031+
" lose\n",
1032+
")\n",
1033+
"gbt_one_card_poker.set_outcome(\n",
1034+
" gbt_one_card_poker.root.children[\"Queen\"].children[\"Fold\"],\n",
1035+
" lose\n",
1036+
")\n",
1037+
"\n",
10231038
"# Bob sees Alice Bet and calls, correctly believing she is bluffing, Bob wins big\n",
1024-
"gbt_one_card_poker.set_outcome(gbt_one_card_poker.root.children[\"Queen\"].children[\"Bet\"].children[\"Call\"], lose_big)\n",
1039+
"gbt_one_card_poker.set_outcome(\n",
1040+
" gbt_one_card_poker.root.children[\"Queen\"].children[\"Bet\"].children[\"Call\"],\n",
1041+
" lose_big\n",
1042+
")\n",
10251043
"\n",
10261044
"# Bob sees Alice Bet and calls, incorrectly believing she is bluffing, Alice wins big\n",
1027-
"gbt_one_card_poker.set_outcome(gbt_one_card_poker.root.children[\"King\"].children[\"Bet\"].children[\"Call\"], win_big)\n",
1045+
"gbt_one_card_poker.set_outcome(\n",
1046+
" gbt_one_card_poker.root.children[\"King\"].children[\"Bet\"].children[\"Call\"],\n",
1047+
" win_big\n",
1048+
")\n",
10281049
"\n",
10291050
"# Bob does not call Alice's Bet, Alice wins small\n",
1030-
"gbt_one_card_poker.set_outcome(gbt_one_card_poker.root.children[\"King\"].children[\"Bet\"].children[\"Fold\"], win)\n",
1031-
"gbt_one_card_poker.set_outcome(gbt_one_card_poker.root.children[\"Queen\"].children[\"Bet\"].children[\"Fold\"], win)"
1051+
"gbt_one_card_poker.set_outcome(\n",
1052+
" gbt_one_card_poker.root.children[\"King\"].children[\"Bet\"].children[\"Fold\"],\n",
1053+
" win\n",
1054+
")\n",
1055+
"gbt_one_card_poker.set_outcome(\n",
1056+
" gbt_one_card_poker.root.children[\"Queen\"].children[\"Bet\"].children[\"Fold\"],\n",
1057+
" win\n",
1058+
")"
10321059
]
10331060
},
10341061
{

0 commit comments

Comments
 (0)