Skip to content

Commit

Permalink
Merge pull request google-deepmind#1049 from rezunli96:nash_avg
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 524798649
Change-Id: I7c791d53abc056865448e83edff0058f0ae9dccc
  • Loading branch information
lanctot committed Apr 17, 2023
2 parents ca8affc + 640bad8 commit 1e0c18e
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions open_spiel/python/algorithms/nash_averaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,11 @@ def nash_averaging(game, eps=0.0, a_v_a=True):
# game does not have to be symmetric

m, n = p_mat[0].shape
a_mat = np.block([[np.zeros(shape=(m, m)), p_mat[0]],
[-p_mat[0].T, np.zeros(shape=(n, n))]])
min_payoffs = np.min(p_mat[0], axis=1).reshape((m, 1))
max_payoffs = np.max(p_mat[0], axis=1).reshape((m, 1))
std_p_mat = (p_mat[0] - min_payoffs)/(max_payoffs-min_payoffs)
a_mat = np.block([[np.zeros(shape=(m, m)), std_p_mat],
[-std_p_mat.T, np.zeros(shape=(n, n))]])
maxent_nash = np.array(_max_entropy_symmetric_nash(a_mat, eps=eps))
pa, pe = maxent_nash[:m], maxent_nash[m:]
return (pa, pe), (p_mat[0].dot(pe), -p_mat[0].T.dot(pa))
return (pa, pe), (std_p_mat.dot(pe), -std_p_mat.T.dot(pa))

0 comments on commit 1e0c18e

Please sign in to comment.