GameTheory.jl
GameTheory.jl copied to clipboard
"Getter" for `payoff_arrays`
What is the proper Julia counterpart of QuantEcon/QuantEcon.py#382?
-
Add a field
payoff_arrays
toNormalFormGame
:struct NormalFormGame{N,T<:Real} players::NTuple{N,Player{N,T}} nums_actions::NTuple{N,Int} payoff_arrays::NTuple{N,Array{T,N}} end
This seems not to be very Julian? And this requires adding the same code of generating the tuple to many constructors.
-
Add a method
payoff_arrays
toNormalFormGame
:payoff_arrays(g::NormalFormGame{N,T}) where {N,T} = tuple([player.payoff_array for player in g.players]...)::NTuple{N,Array{T,N}}
This is what I had in mind initially, but now I want to avoid this as it will introduce a conflict with the likely usage of
payoff_arrays
as a variable name. -
Name the above method
get_payoff_arrays
:Sounds too long? And to "get" payoff arrays, one could just call
g.players[i].payoff_array
.