Exporting to latex#
To export to your game model to latex, use the export_latex() method of the game class.
>>> example_game.export_latex()
parameters:
scale: An optional scale in float, scaling the final resulting latex figure (default 2.5)file_path: an optional filepath and filename of the output.tex fileUsage:
>>> # Exports the game with scale 1.5 as figure.tex in an output folder
>>> example_game.export_latex(1.5, "output/figure.tex")
>>> game.export_latex() # exports the raw latex code to the terminal
Make sure the output folder is created, or an error will occur.
After creating the latex, further styling can be done manually. Instead of bogging the function down with optional parameters, simplicity was favored.
Example:
>>> # Game Configurations
>>> game5_1a = Game(title="Model 1a", player_num=2)
>>> p1, p2 = game5_1a.player[1], game5_1a.player[2]
>>> p1.name = "South Korea"
>>> p2.name = "Japan"
>>> # Creating Utility Variables
>>> s1, s2 = Variable("S_1"), Variable("S_2")
>>> d1, d2 = Variable("D_1"), Variable("D_2")
>>> g, c = Variable("G"), Variable("C")
>>> # setting the players preferences
>>> g > s1 > d1
>>> s2 > c > d2
>>> # Adding nodes
>>> (game5_1a + Decision(p1, "Refrain", variable=(s1, s2))
>>> + (Decision(p1, "Persist") + Decision(p2, "Punish", variable=(d1, d2)) +
>>> Decision(p2, "Ignore", variable=(g, c))))
>>>
>>> game5_1a.export_latex(1.5, output_dir + "5-1a.tex")
This code will result in latex code that will generate the following:
