GameTheory.jl icon indicating copy to clipboard operation
GameTheory.jl copied to clipboard

"Getter" for `payoff_arrays`

Open oyamad opened this issue 7 years ago • 0 comments

What is the proper Julia counterpart of QuantEcon/QuantEcon.py#382?

  1. Add a field payoff_arrays to NormalFormGame:

    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.

  2. Add a method payoff_arrays to NormalFormGame:

    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.

  3. Name the above method get_payoff_arrays:

    Sounds too long? And to "get" payoff arrays, one could just call g.players[i].payoff_array.

oyamad avatar Jan 08 '18 07:01 oyamad