|
31 | 31 | }, |
32 | 32 | { |
33 | 33 | "cell_type": "code", |
34 | | - "execution_count": null, |
| 34 | + "execution_count": 1, |
35 | 35 | "id": "5946289b", |
36 | 36 | "metadata": {}, |
37 | 37 | "outputs": [], |
|
51 | 51 | }, |
52 | 52 | { |
53 | 53 | "cell_type": "code", |
54 | | - "execution_count": 10, |
| 54 | + "execution_count": 2, |
55 | 55 | "id": "91ed4dfb", |
56 | 56 | "metadata": {}, |
57 | 57 | "outputs": [], |
|
72 | 72 | }, |
73 | 73 | { |
74 | 74 | "cell_type": "code", |
75 | | - "execution_count": 11, |
| 75 | + "execution_count": 3, |
76 | 76 | "id": "3cd94917", |
77 | 77 | "metadata": {}, |
78 | 78 | "outputs": [ |
79 | | - { |
80 | | - "name": "stdout", |
81 | | - "output_type": "stream", |
82 | | - "text": [ |
83 | | - "Writing .ef file to: One-shot trust game, after Kreps (1990).ef\n" |
84 | | - ] |
85 | | - }, |
86 | 79 | { |
87 | 80 | "data": { |
88 | 81 | "image/svg+xml": [ |
|
107 | 100 | "<IPython.core.display.SVG object>" |
108 | 101 | ] |
109 | 102 | }, |
110 | | - "execution_count": 11, |
| 103 | + "execution_count": 3, |
111 | 104 | "metadata": {}, |
112 | 105 | "output_type": "execute_result" |
113 | 106 | } |
|
128 | 121 | }, |
129 | 122 | { |
130 | 123 | "cell_type": "code", |
131 | | - "execution_count": 12, |
| 124 | + "execution_count": 4, |
132 | 125 | "id": "5d27a07a", |
133 | 126 | "metadata": {}, |
134 | 127 | "outputs": [], |
|
142 | 135 | }, |
143 | 136 | { |
144 | 137 | "cell_type": "code", |
145 | | - "execution_count": 13, |
| 138 | + "execution_count": 5, |
146 | 139 | "id": "45638fda-7e25-4c8e-b709-24b05780581b", |
147 | 140 | "metadata": {}, |
148 | 141 | "outputs": [ |
149 | | - { |
150 | | - "name": "stdout", |
151 | | - "output_type": "stream", |
152 | | - "text": [ |
153 | | - "Writing .ef file to: One-shot trust game, after Kreps (1990).ef\n" |
154 | | - ] |
155 | | - }, |
156 | 142 | { |
157 | 143 | "data": { |
158 | 144 | "image/svg+xml": [ |
|
267 | 253 | "<IPython.core.display.SVG object>" |
268 | 254 | ] |
269 | 255 | }, |
270 | | - "execution_count": 13, |
| 256 | + "execution_count": 5, |
271 | 257 | "metadata": {}, |
272 | 258 | "output_type": "execute_result" |
273 | 259 | } |
|
286 | 272 | }, |
287 | 273 | { |
288 | 274 | "cell_type": "code", |
289 | | - "execution_count": 14, |
| 275 | + "execution_count": 6, |
290 | 276 | "id": "47c4a31b", |
291 | 277 | "metadata": {}, |
292 | 278 | "outputs": [], |
|
300 | 286 | }, |
301 | 287 | { |
302 | 288 | "cell_type": "code", |
303 | | - "execution_count": 15, |
| 289 | + "execution_count": 7, |
304 | 290 | "id": "ce41e9fe-cca4-46fb-8e9d-b2c27342e5ef", |
305 | 291 | "metadata": {}, |
306 | 292 | "outputs": [ |
307 | | - { |
308 | | - "name": "stdout", |
309 | | - "output_type": "stream", |
310 | | - "text": [ |
311 | | - "Writing .ef file to: One-shot trust game, after Kreps (1990).ef\n" |
312 | | - ] |
313 | | - }, |
314 | 293 | { |
315 | 294 | "data": { |
316 | 295 | "image/svg+xml": [ |
|
476 | 455 | "<IPython.core.display.SVG object>" |
477 | 456 | ] |
478 | 457 | }, |
479 | | - "execution_count": 15, |
| 458 | + "execution_count": 7, |
480 | 459 | "metadata": {}, |
481 | 460 | "output_type": "execute_result" |
482 | 461 | } |
|
499 | 478 | }, |
500 | 479 | { |
501 | 480 | "cell_type": "code", |
502 | | - "execution_count": 16, |
| 481 | + "execution_count": 8, |
503 | 482 | "id": "716e9b9a", |
504 | 483 | "metadata": {}, |
505 | 484 | "outputs": [], |
|
515 | 494 | }, |
516 | 495 | { |
517 | 496 | "cell_type": "code", |
518 | | - "execution_count": 17, |
| 497 | + "execution_count": 9, |
519 | 498 | "id": "b3408c55-714e-4a6f-b598-e338839442e4", |
520 | 499 | "metadata": {}, |
521 | 500 | "outputs": [ |
522 | | - { |
523 | | - "name": "stdout", |
524 | | - "output_type": "stream", |
525 | | - "text": [ |
526 | | - "Writing .ef file to: One-shot trust game, after Kreps (1990).ef\n" |
527 | | - ] |
528 | | - }, |
529 | 501 | { |
530 | 502 | "data": { |
531 | 503 | "image/svg+xml": [ |
|
677 | 649 | "<IPython.core.display.SVG object>" |
678 | 650 | ] |
679 | 651 | }, |
680 | | - "execution_count": 17, |
| 652 | + "execution_count": 9, |
681 | 653 | "metadata": {}, |
682 | 654 | "output_type": "execute_result" |
683 | 655 | } |
|
696 | 668 | }, |
697 | 669 | { |
698 | 670 | "cell_type": "code", |
699 | | - "execution_count": 18, |
| 671 | + "execution_count": 10, |
700 | 672 | "id": "695b1aad", |
701 | 673 | "metadata": {}, |
702 | 674 | "outputs": [], |
|
712 | 684 | }, |
713 | 685 | { |
714 | 686 | "cell_type": "code", |
715 | | - "execution_count": 19, |
| 687 | + "execution_count": 11, |
716 | 688 | "id": "09bedb3a-aac7-46e6-ae93-c47932c746d4", |
717 | 689 | "metadata": {}, |
718 | 690 | "outputs": [ |
719 | | - { |
720 | | - "name": "stdout", |
721 | | - "output_type": "stream", |
722 | | - "text": [ |
723 | | - "Writing .ef file to: One-shot trust game, after Kreps (1990).ef\n" |
724 | | - ] |
725 | | - }, |
726 | 691 | { |
727 | 692 | "data": { |
728 | 693 | "image/svg+xml": [ |
|
888 | 853 | "<IPython.core.display.SVG object>" |
889 | 854 | ] |
890 | 855 | }, |
891 | | - "execution_count": 19, |
| 856 | + "execution_count": 11, |
892 | 857 | "metadata": {}, |
893 | 858 | "output_type": "execute_result" |
894 | 859 | } |
|
907 | 872 | }, |
908 | 873 | { |
909 | 874 | "cell_type": "code", |
910 | | - "execution_count": 20, |
| 875 | + "execution_count": 12, |
911 | 876 | "id": "0704ef86", |
912 | 877 | "metadata": {}, |
913 | 878 | "outputs": [], |
|
923 | 888 | }, |
924 | 889 | { |
925 | 890 | "cell_type": "code", |
926 | | - "execution_count": 21, |
| 891 | + "execution_count": 13, |
927 | 892 | "id": "cba0e562-2989-4dae-a0f0-b121635ba032", |
928 | 893 | "metadata": {}, |
929 | 894 | "outputs": [ |
930 | | - { |
931 | | - "name": "stdout", |
932 | | - "output_type": "stream", |
933 | | - "text": [ |
934 | | - "Writing .ef file to: One-shot trust game, after Kreps (1990).ef\n" |
935 | | - ] |
936 | | - }, |
937 | 895 | { |
938 | 896 | "data": { |
939 | 897 | "image/svg+xml": [ |
|
1095 | 1053 | "<IPython.core.display.SVG object>" |
1096 | 1054 | ] |
1097 | 1055 | }, |
1098 | | - "execution_count": 21, |
| 1056 | + "execution_count": 13, |
1099 | 1057 | "metadata": {}, |
1100 | 1058 | "output_type": "execute_result" |
1101 | 1059 | } |
|
1125 | 1083 | "You can use Gambit to save games to, and read from files.\n", |
1126 | 1084 | "The specific format depends on whether the game is normal or extensive-form.\n", |
1127 | 1085 | "\n", |
1128 | | - "Here we'll save the Trust game (extensive-form) to the `.efg` format." |
| 1086 | + "Here we'll save the Trust game (extensive-form) to the `.efg` format.\n", |
| 1087 | + "Uncomment these lines of code if you're running the tutorial locally:" |
1129 | 1088 | ] |
1130 | 1089 | }, |
1131 | 1090 | { |
1132 | 1091 | "cell_type": "code", |
1133 | | - "execution_count": 22, |
| 1092 | + "execution_count": 14, |
1134 | 1093 | "id": "37c51152", |
1135 | 1094 | "metadata": {}, |
1136 | 1095 | "outputs": [], |
|
1148 | 1107 | }, |
1149 | 1108 | { |
1150 | 1109 | "cell_type": "code", |
1151 | | - "execution_count": 23, |
| 1110 | + "execution_count": 15, |
1152 | 1111 | "id": "0d86a750", |
1153 | 1112 | "metadata": {}, |
1154 | 1113 | "outputs": [], |
1155 | 1114 | "source": [ |
1156 | 1115 | "# gbt.read_efg(\"trust_game.efg\")" |
1157 | 1116 | ] |
1158 | 1117 | }, |
| 1118 | + { |
| 1119 | + "cell_type": "markdown", |
| 1120 | + "id": "182f2424-274e-4044-84ff-3323cd70ec68", |
| 1121 | + "metadata": {}, |
| 1122 | + "source": [ |
| 1123 | + "You can also use the `draw_tree` package to save the game in the `.ef` format which encodes layout information.\n", |
| 1124 | + "This can in turn be used to render the image for use in publications, for example as a `.png` (there are also `.pdf` and `.tex` options, see [draw_tree](https://github.com/gambitproject/draw_tree)):" |
| 1125 | + ] |
| 1126 | + }, |
1159 | 1127 | { |
1160 | 1128 | "cell_type": "code", |
1161 | | - "execution_count": null, |
| 1129 | + "execution_count": 18, |
1162 | 1130 | "id": "1bab777f-8a0b-4f1e-9c0c-270690288243", |
1163 | 1131 | "metadata": {}, |
1164 | 1132 | "outputs": [], |
1165 | | - "source": [] |
| 1133 | + "source": [ |
| 1134 | + "# from draw_tree import generate_png\n", |
| 1135 | + "# draw_tree(g, save_to=\"trust_game.ef\")\n", |
| 1136 | + "# trust_game_png = generate_png(\"trust_game.ef\")" |
| 1137 | + ] |
| 1138 | + }, |
| 1139 | + { |
| 1140 | + "cell_type": "code", |
| 1141 | + "execution_count": 19, |
| 1142 | + "id": "2b715221-e427-4092-ad2f-9f4f2b548fa4", |
| 1143 | + "metadata": {}, |
| 1144 | + "outputs": [], |
| 1145 | + "source": [ |
| 1146 | + "# from IPython.display import Image\n", |
| 1147 | + "# Image(trust_game_png)" |
| 1148 | + ] |
1166 | 1149 | }, |
1167 | 1150 | { |
1168 | 1151 | "cell_type": "markdown", |
|
1173 | 1156 | "\n", |
1174 | 1157 | "Kreps, D. (1990) \"Corporate Culture and Economic Theory.\" In J. Alt and K. Shepsle, eds., *Perspectives on Positive Political Economy*, Cambridge University Press." |
1175 | 1158 | ] |
1176 | | - }, |
1177 | | - { |
1178 | | - "cell_type": "code", |
1179 | | - "execution_count": null, |
1180 | | - "id": "ddf390ee-5d99-41a9-bfd9-7df86e372d5b", |
1181 | | - "metadata": {}, |
1182 | | - "outputs": [], |
1183 | | - "source": [] |
1184 | 1159 | } |
1185 | 1160 | ], |
1186 | 1161 | "metadata": { |
1187 | 1162 | "kernelspec": { |
1188 | | - "display_name": "gambitvenv313", |
| 1163 | + "display_name": "Python 3 (ipykernel)", |
1189 | 1164 | "language": "python", |
1190 | 1165 | "name": "python3" |
1191 | 1166 | }, |
|
0 commit comments