-
-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pure strategy nash equilibrium #12
Changes from 1 commit
589df64
f67b47d
e836c4f
11cc6ac
904dd27
517785c
42d572e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,21 @@ | ||
module Games | ||
|
||
# Packages | ||
|
||
# package code goes here | ||
include("normal_form_game.jl") | ||
include("nash_equilibrium.jl") | ||
|
||
export Player, NormalFormGame, # Types | ||
|
||
export Player, NormalFormGame, | ||
# Type aliases | ||
Action, MixedAction, PureAction, ActionProfile, | ||
|
||
# Normal form game functions | ||
best_response, best_responses, is_best_response, payoff_vector, | ||
is_nash, pure2mixed, num_players, num_actions, num_opponents | ||
is_nash, pure2mixed, pure_strategy_NE, | ||
|
||
# General functions | ||
num_players, num_actions, num_opponents | ||
|
||
end # module |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
""" | ||
Finds all pure strategy Nash equilibrium for a normal form | ||
game. It returns an empty array if there are no nash | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. are -> is |
||
equilibrium | ||
""" | ||
function pure_strategy_NE(nfg::NormalFormGame) | ||
# Get number of players and their actions | ||
np = num_players(nfg) | ||
na = nfg.nums_actions | ||
|
||
# Holder for all NE | ||
ne = Array(ActionProfile, 0) | ||
|
||
# For each action profile check whether it is NE | ||
as = CartesianRange(na) | ||
for a in as | ||
_a = a.I::NTuple{np, Int} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Having to insert type checks is never a great thing because (I believe) it incurs minor runtime cost. It might be better to add a method |
||
is_nash(nfg, _a) ? push!(ne, _a) : nothing | ||
end | ||
|
||
return ne | ||
end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
strategy -> action
equilibrium -> equilibria
(or just "pure Nash equilibria")