<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 N Player Game
Iterated Peace War Game
I've created a version of the peace war game. The scenario for this game is members of lcdm own companies across the united states.
Companies in this game have 3 actions
Step1:  Configuring stuff for visualizations
Step2:  Playing Peace War Game with 14 Players for 650,000 iterations
Step3:  Grabbing scores of each agent
Step4:  Converting current score number range to smaller range maintaining ratio
Step5:  Displaying Scores and Summary of Game
Step6:  (The Interactive Map may not be rendered on Github)
<ASSISTANT_TASK:>
Python Code:
import gmaps, os  # Used for interactive visualizations
from game_types import NPlayerGame
import tensorflow as tf
import pandas as pd
Explanation: N Player Game
Iterated Peace War Game
I've created a version of the peace war game. The scenario for this game is members of lcdm own companies across the united states.
Companies in this game have 3 actions: peace, compromise, or war. If a company (or agent) chooses peace they are looking for peaceful solutions with rival agents. If an agent chooses comprimise they are willing to find some middle ground but have taken certain precautions to ensure that they are in a better position if a rival agent chooses war. If an agent chooses war they are willing to inflict harm to other agents in order to achieve a greater payoff than the other 2 actions. The Payoff matrix for 2 players:
The Payoff matrices for 3 players are below:
This payoff matrix contains the utility values of all possible outcomes if the 3rd agent chooses the peace action.
This payoff matrix contains the utility values of all possible outcomes if the 3rd agent chooses the compromise action.
This payoff matrix contains the utility values of all possible outcomes if the 3rd agent chooses the war action.
I could continue to write payoff matrices up to N Players however it becomes tedious to represent all possible states using payoff matrices, ergo game trees are usually used for iterated or N Player Games.
End of explanation
gmaps.configure(api_key=os.environ["GOOGLE_API_KEY"])
locs = [
    [(37.760851, -122.443118), (37.760853, -122.443120)],  # Silcon Valley
    [(40.092034, -88.238687), (40.092035, -88.238688)],  # Urbana
    [(25.777052, -80.194957), (25.777054, -80.194959)],  # Flordia
    [(40.705773, -74.010861), (40.705774, -74.010863)],  # Manhattan
    [(35.898512, -78.865059), (35.898513, -78.865060)],  #  NC
    [(42.278052, -83.738997), (42.278053, -83.738998)],  # Michigan
    [(35.844058, -106.287484), (35.844059, -106.287485)],  # New Mexico
    [(33.745074, -84.390840), (33.745076, -84.390842)],  # Georgia
    [(32.758009, -96.805532), (32.758011, -96.805534)],  # Texas
    [(47.653022, -122.305569), (47.653024, -122.305571)],  # Washington
    [(47.653532, -100.347697), (47.653533, -100.347698)],  # ND
    [(34.069110, -118.246972), (34.069112, -118.246974)],  # Sol Cal
    [(44.723362, -111.071472), (44.723363, -111.071473)]  # WY
]
names = ['Silcon Valley', 'Illinois', 'Flordia', 'Manhattan', 'North Carolina',
         'Michigan', 'New Mexico', 'Georgia', 'Texas', 'Washington', 'North Dakota', 'Sol Cal', 'Wyoming']
Explanation: Configuring stuff for visualizations
End of explanation
tf.reset_default_graph()
game = NPlayerGame(n_players=14) # Create 13 agents of random type
game.play(650000) # Play 600,000 iterations
Explanation: Playing Peace War Game with 14 Players for 650,000 iterations
End of explanation
agent_name, agent_score = [], []
for agent in game.data:
    if agent != 'id':
        agent_name.append(agent)
        agent_score.append(sum(game.data[agent]))
Explanation: Grabbing scores of each agent
End of explanation
old_range = max(agent_score) - min(agent_score)
new_range = 35
new_agent_scores = []
for old_val in agent_score:
    new_agent_scores.append( (((old_val-min(agent_score))*new_range)/old_range) + 10 ) 
#print(old_range)
Explanation: Converting current score number range to smaller range maintaining ratio
End of explanation
layers = []
fig = gmaps.Map()
#print('Agent Name \t\t\t| Location  \t\t\t|  Total Score')
for i, loc in enumerate(locs):
    #print('{0} \t\t\t| {1} \t\t\t| \t\t{2}'.format(agent_name[i], names[i], new_agent_scores[i]))
    _layer = gmaps.heatmap_layer(loc, point_radius=int(new_agent_scores[i]))
    fig.add_layer(_layer)
d ={'Agent Name': agent_name, 'Location': names, 'Total Score': agent_score, 'Radius Size': new_agent_scores}
fig
Explanation: Displaying Scores and Summary of Game:
End of explanation
pd.DataFrame(d)
Explanation: (The Interactive Map may not be rendered on Github)
End of explanation
<END_TASK>