Ejemplo n.º 1
0
from main import units, town_colors, chart_data_path
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import os

tiers = (4, 5)
state = "upgraded"
title = 'gold cost of maximum growth for each town, units tiers 4-5'

units = units.query(
    f'tier >= {tiers[0]} & tier <= {tiers[1]} & state == "{state}"')
units["max_gold_cost"] = units.max_growth * units.gold_cost
print(units[units["fraction"] == 'rampart'])
t = pd.DataFrame(
    index=[town for town in town_colors.keys() if town != 'neutral'])
t["max_gold_cost"] = units.groupby(["fraction"])['max_gold_cost'].sum()

t = t.sort_values(by="max_gold_cost", ascending=False)

indexes = t.index.values
colors_in_order = [town_colors[town] for town in indexes]

chart = t.plot(y=0,
               kind='bar',
               color=colors_in_order,
               figsize=(16.5, 8.5),
               xlabel="towns",
               ylabel="gold",
               legend=False,
               title=title,
Ejemplo n.º 2
0
from main import units, town_colors, legend_elements, chart_data_path
from common import ehp
import pandas as pd
import matplotlib.pyplot as plt
import os
import seaborn

title = 'Ehp vs 0 attack, basic versions'
chart_name = title
state = 'basic'

units_basic = units.query(f"state == '{state}'")

units_basic = units_basic.assign(ehp=units_basic.apply(ehp.e_hp, axis=1))


units_plot = units_basic[["name", "ehp", "fraction", "tier"]]
units_plot.sort_values(inplace=True, by='ehp', ascending=False)
fig = plt.figure(figsize=(14, 8), dpi=150)
ax = fig.add_subplot(1, 1, 1)


for i in range(len(units_plot)):
    unit = units_plot.iloc[i]
    ax.barh(width=unit["ehp"], color=town_colors[unit["fraction"]], y=unit["name"], align='center')
ax.set_xlabel('Effective health', fontsize=12)
ax.set_ylabel('Unit', fontsize=12)
ax.set_title(title, fontsize=14)
ax.set_yticklabels(labels=units_plot["name"], fontsize=6)
fig.savefig(os.path.join(chart_data_path, chart_name + '.png'))
plt.show()
Ejemplo n.º 3
0
from main import units, town_colors, chart_data_path
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import os

tiers = (1, 3)
state = "upgraded"
title = 'gold cost of maximum growth for each town, units tiers 1-3'

units = units.query(
    f'tier >= {tiers[0]} & tier <= {tiers[1]} & state == "{state}" & name != "corsairs"'
)
units["max_gold_cost"] = units.max_growth * units.gold_cost

t = pd.DataFrame(
    index=[town for town in town_colors.keys() if town != 'neutral'])
t["max_gold_cost"] = units.groupby(["fraction"])['max_gold_cost'].sum()

t = t.sort_values(by="max_gold_cost", ascending=False)

indexes = t.index.values
colors_in_order = [town_colors[town] for town in indexes]

chart = t.plot(y=0,
               kind='bar',
               color=colors_in_order,
               figsize=(16.5, 8.5),
               xlabel="towns",
               ylabel="gold",
               legend=False,
Ejemplo n.º 4
0
from main import units, town_colors, chart_data_path
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import os

tiers = (1, 7)
state = "upgraded"
title_1 = '% of tier 1-3 units cost in overall towns cost'
title_2 = 'gold cost of maximum growth for each town, units tiers 1-3'
chart_name = title_1 + ' + ' + title_2

fig, axes = plt.subplots(nrows=2, ncols=1)

units_all_tiers = units.query(
    f'tier >= {tiers[0]} & tier <= {tiers[1]} & state == "{state}" & name != "corsairs"'
)
units_all_tiers["max_gold_cost"] = units.max_growth * units.gold_cost
t = pd.DataFrame(
    index=[town for town in town_colors.keys() if town != 'neutral'])
t["overall_gold_cost"] = units_all_tiers.groupby(["fraction"
                                                  ])['max_gold_cost'].sum()

tiers = (1, 3)
units_tier_13 = units_all_tiers.query(
    f'tier >= {tiers[0]} & tier <= {tiers[1]}')
t["gold_cost13"] = units_tier_13.groupby(["fraction"])['max_gold_cost'].sum()
t["%"] = t.gold_cost13 / t.overall_gold_cost * 100
t = t.sort_values(by="%", ascending=False)

indexes = t.index.values
Ejemplo n.º 5
0
from main import units, town_colors, legend_elements, chart_data_path
from common import average_damage
import pandas as pd
import matplotlib.pyplot as plt
import os
import seaborn

title = 'Average damage vs 0 defense target, upgraded versions + neutrals'
chart_name = title
state = ['upgraded', 'neutral']

units_basic = units.query(f"state == '{state[0]}' or state== '{state[1]}'")

units_basic = units_basic.assign(
    avg_dmg=units_basic.apply(average_damage.avg_dmg, axis=1))

units_plot = units_basic[["name", "avg_dmg", "fraction", "tier"]]
units_plot.sort_values(inplace=True, by='avg_dmg', ascending=False)
fig = plt.figure(figsize=(14, 8), dpi=150)
ax = fig.add_subplot(1, 1, 1)

for i in range(len(units_plot)):
    unit = units_plot.iloc[i]
    ax.barh(width=unit["avg_dmg"],
            color=town_colors[unit["fraction"]],
            y=unit["name"],
            align='center')
ax.tick_params(axis='x', labelsize=5)
ax.set_xlabel('Average damage', fontsize=8)
ax.set_ylabel('Unit', fontsize=8)
ax.set_title(title, fontsize=8)
Ejemplo n.º 6
0
from main import units, town_colors, chart_data_path
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import os


tiers = (1, 7)
state = "upgraded"
title_1 = '% of tier 6-7 units cost in overall towns cost'
title_2 = 'gold cost of maximum growth for each town, units tiers 6-7'
chart_name = title_1 + ' + ' + title_2

fig, axes = plt.subplots(nrows=2, ncols=1)

units_all_tiers = units.query(f'tier >= {tiers[0]} & tier <= {tiers[1]} & state == "{state}"')
units_all_tiers["max_gold_cost"] = units.max_growth * units.gold_cost
t = pd.DataFrame(index=[town for town in town_colors.keys() if town != 'neutral'])
t["overall_gold_cost"] = units_all_tiers.groupby(["fraction"])['max_gold_cost'].sum()

tiers = (6, 7)
units_tier_45 = units_all_tiers.query(f'tier >= {tiers[0]} & tier <= {tiers[1]}')
t["gold_cost13"] = units_tier_45.groupby(["fraction"])['max_gold_cost'].sum()
t["%"] = t.gold_cost13 / t.overall_gold_cost * 100
t = t.sort_values(by="%", ascending=False)

indexes = t.index.values
colors_in_order = [town_colors[town] for town in indexes]

chart = t.plot(ax=axes[0], y=2, kind='bar', color=colors_in_order, figsize=(18, 10), xlabel="towns", ylabel="%", legend=False,
       title=title_1, rot=0, ylim=(30, 55))
from main import units, town_colors, legend_elements, chart_data_path
from common import average_damage
import pandas as pd
import matplotlib.pyplot as plt
import os

set_damage = 500
title = f'number of maximum growths and gold needed to reach {set_damage} damage'
chart_name = title
states = ['upgraded', 'neutral']

units_up_and_neu = units.query(
    f'state == "{states[0]}" or state == "{states[1]}"')

units_up_and_neu = units_up_and_neu.assign(
    avg_dmg=units_up_and_neu.apply(average_damage.avg_dmg, axis=1))
units_up_and_neu["growths"] = (set_damage / units_up_and_neu.avg_dmg /
                               units_up_and_neu.max_growth).round(0)
units_up_and_neu[
    "gold_req"] = units_up_and_neu.growths * units_up_and_neu.gold_cost / 1000

units_to_chart = units_up_and_neu[["name", "fraction", "growths", "gold_req"]]
w = 0.6
chart = units_to_chart.sort_values('growths', ascending=True).plot(
    x=0,
    kind="barh",
    stacked=True,
    figsize=(18, 10),
    width=w,
    fontsize=6,
    ylabel="growths, gold in thousands",