Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f86023e

Browse files
author
Lorenzo
committed
Final commit
1 parent 849c62d commit f86023e

File tree

3 files changed

+20
-41
lines changed

3 files changed

+20
-41
lines changed

‎Main.py‎

Lines changed: 5 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616

1717
'''Setting up strategies and relative proportions'''
18-
'''
18+
1919
strategies = [Strategies.Aselect(), Strategies.EGreedy(), Strategies.UCB(), Strategies.Satisficing(),
2020
Strategies.Softmax(), Strategies.FictitiousPlay(), Strategies.Bully(),
2121
Strategies.ProportionalRegretMatching()]
@@ -47,13 +47,12 @@ def game_session(game_id: int, matrix_suite: MatrixSuite, strategies: List[Strat
4747

4848
grand_table.play_games()
4949
print(grand_table)
50-
grand_table.to_latex("Game_" + str(game_id))
50+
# grand_table.to_latex("Game_" + str(game_id))
5151

52-
i = 1
53-
for proportion in proportions:
52+
for i, proportion in enumerate(proportions):
5453
replicator_dynamic = ReplicatorDynamic(grand_table)
55-
replicator_dynamic.run(proportion, name="Game_" + str(game_id) + "_" + str(i))
56-
i+=1
54+
replicator_dynamic.run(proportion, name="Game_" + str(game_id) + "_" + str(i+1))
55+
5756

5857
print("Gambit test result:")
5958
Nash.nash_equilibria(strategies, grand_table)
@@ -74,37 +73,4 @@ def game_session(game_id: int, matrix_suite: MatrixSuite, strategies: List[Strat
7473

7574

7675

77-
'''
78-
############# TEST AREA
79-
print("BEGIN ########################################\n")
80-
81-
82-
matrix_suite = RandomIntMatrixSuite() # Create a matrix suite
83-
84-
row_strat = Strategies.Softmax() # Create the strategy you want to test.
85-
col_strat = Strategies.Softmax()
86-
row_strat.initialize(matrix_suite, "row") # Initialise it with the game suite and as either "row" or "col" player.
87-
col_strat.initialize(matrix_suite, "col")
88-
89-
for round in range(0, 500):
90-
row_action = row_strat.get_action(round) # Get the next action
91-
col_action = col_strat.get_action(round)
92-
print("Row plays action:" + row_action.__repr__())
93-
print("Col plays action:" + col_action.__repr__())
94-
95-
row_payoff, col_payoff = matrix_suite.get_payoffs(row_action, col_action)
96-
print("Payoff: " + str((row_payoff,col_payoff)))
97-
98-
row_strat.update(round, row_action, row_payoff, col_action)
99-
col_strat.update(round, col_action, col_payoff, row_action)# Update the strategy with a fake payoff and opponent action.
100-
# Now you might want to look at the class attributes of the strategy,
101-
# which you can call the same as functions, just without any parentheses.
102-
print("UCB actions:")
103-
print(row_strat.actions, " ROW")
104-
print(col_strat.actions, " COL")
105-
print()
106-
107-
108-
print("END ########################################\n")
109-
########################
11076

‎README.txt‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,14 @@
1-
#TODO
1+
The program makes use of the Python libraries numpy, matplotlib.
2+
The program needs Gambit to compute Nash equilibria correctly. If not installed, download and install
3+
Gambit 15:
4+
http://www.gambit-project.org/
5+
6+
Copy the gambit-enummixed.exe executable from the installation folder to the folder containing the Nash.py script.
7+
8+
To store the images from the replicator dynamic, create a folder "/img" inside the folder containing the
9+
Main.py script.
10+
The method game_session() in Main.py contains a call to to_latex() of GrandTable.py. This method converts the
11+
resulting grand table of the game into a formatted table suitable for LaTeX. To store the tables, create a
12+
folder "/grand_table" inside the folder containing the Main.py script.
13+
14+
Run Main.py to play the games and compute the statistics.

‎Strategies.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ class Softmax(Strategy):
231231
*temperature*: The temperature for the softmax distribution computation
232232
*action_history*: History of all played actions in the current session
233233
*qmatrix*: Moving average of payoffs for each instance of *actions*
234-
*probmatrix*: Softmax probability distribution for the *actions*
234+
*probmatrix*: Softmax probability distribution for each instance of *actions*
235235
"""
236236
actions: List[Action]
237237
learning_rate: float

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /