From 2a6e885d06f11fba73e1e4978c4dc2486c120cef Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Sun, 17 Sep 2023 21:32:55 +0200 Subject: [PATCH] [MIRROR] Fixes silo graphing tool [MDB IGNORE] (#23747) * Fixes silo graphing tool (#78346) ## About The Pull Request Looks like we made some changes to the standard silo.json log files produced on the public logs. This fixes the silo_graph_script tool so that it works properly again. ## Why It's Good For The Game It's good for us to host tools that are downloaded with the base code to actually work. ## Changelog Zero player facing changes. ## BONUS TEXT Unrelated, but here's the silo graphing tool's output, taken on a new sample study of 224 rounds I took the past few days! ************Grand totals************ (Total material sheets consumed over all rounds) iron net: 47596.13 | spent total: 103975.14 | obtained total: 151571.27 glass net: 34136.42 | spent total: 33126.63 | obtained total: 67263.05 silver net: 17185.94 | spent total: 5885.23 | obtained total: 23071.17 gold net: 14934.01 | spent total: 7654.18 | obtained total: 22588.19 uranium net: 9592.75 | spent total: 3910.68 | obtained total: 13503.43 titanium net: 16823.75 | spent total: 3483.5 | obtained total: 20307.25 bluespace crystal net: 2736.84 | spent total: 2126.68 | obtained total: 4863.52 diamond net: 4318.85 | spent total: 2211.15 | obtained total: 6530.0 plasma net: 26496.6 | spent total: 11724.65 | obtained total: 38221.25 bananium net: 729.05 | spent total: 85.95 | obtained total: 815.0 plastic net: 2823.02 | spent total: 1292.98 | obtained total: 4116.0 ************AVERAGES************ (Average material sheets consumed per round paired with their percentages utilized) iron net: 213.44 | spent total: 466.26 | obtained total: 679.69 | percentage spent: 68.60% glass net: 153.08 | spent total: 148.55 | obtained total: 301.63 | percentage spent: 49.25% silver net: 77.07 | spent total: 26.39 | obtained total: 103.46 | percentage spent: 25.51% gold net: 66.97 | spent total: 34.32 | obtained total: 101.29 | percentage spent: 33.89% uranium net: 43.02 | spent total: 17.54 | obtained total: 60.55 | percentage spent: 28.96% titanium net: 75.44 | spent total: 15.62 | obtained total: 91.06 | percentage spent: 17.15% bluespace crystal net: 12.27 | spent total: 9.54 | obtained total: 21.81 | percentage spent: 43.73% diamond net: 19.37 | spent total: 9.92 | obtained total: 29.28 | percentage spent: 33.86% plasma net: 118.82 | spent total: 52.58 | obtained total: 171.4 | percentage spent: 30.68% bananium net: 3.27 | spent total: 0.39 | obtained total: 3.65 | percentage spent: 10.55% plastic net: 12.66 | spent total: 5.8 | obtained total: 18.46 | percentage spent: 31.41% This is equivalent to a total of an average **117616** mineral tiles (Assuming mean output), or **527** mineral walls mined per round. * Fixes silo graphing tool --------- Co-authored-by: ArcaneMusic <41715314+ArcaneMusic@users.noreply.github.com> --- tools/silo_grapher/silo_graph_script.py | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/tools/silo_grapher/silo_graph_script.py b/tools/silo_grapher/silo_graph_script.py index 8b09ed836b6..bd39549d124 100644 --- a/tools/silo_grapher/silo_graph_script.py +++ b/tools/silo_grapher/silo_graph_script.py @@ -11,6 +11,7 @@ import os import matplotlib.pyplot as plt show_json_figures = False # Set to True to show all JSON-specific figures at the end +sheet_amount = 100 # How many units of material are a sheet worth right now? materials = { "iron": {"total": 0, "spent": 0, "obtained": 0}, @@ -40,11 +41,13 @@ grand_total = { "plastic": {"grand_total": 0, "grand_spent": 0, "grand_obtained": 0}, } -log_folder = "logs" +log_folder = "tools\silo_grapher\logs" total_files = 0 first_time_value = None first_time_setup = True +total_ores_mined = 0 + for filename in os.listdir(log_folder): with open(os.path.join(log_folder, filename), "r") as file: total_files += 1 @@ -60,7 +63,7 @@ for filename in os.listdir(log_folder): log = json.loads(line) raw_materials = log.get("data", {}).get("raw_materials", "") if first_time_setup: - first_time_value = log["timestamp"] + first_time_value = float(log["ts"]) first_time_setup = False if not raw_materials: continue @@ -73,7 +76,8 @@ for filename in os.listdir(log_folder): else: materials[material]["obtained"] += int(quantity[1:]) materials[material]["total"] += int(quantity[1:]) - time[material].append((int(log["timestamp"]) - int(first_time_value)) / 10) + total_ores_mined += int(quantity[1:]) + time[material].append((float(log["w-state"]["timestamp"]) - float(first_time_value)) / 10.0) y[material].append(int(materials[material]["total"])) except Exception as e: @@ -116,12 +120,18 @@ plt.show() for material, values in grand_total.items(): if values["grand_obtained"] != 0: - grand_total[material]["grand_spent_percentage"] = values["grand_spent"] / values["grand_obtained"] * 100 + grand_total[material]["grand_spent_percentage"] = values["grand_spent"] / values["grand_obtained"] * sheet_amount else: grand_total[material]["grand_spent_percentage"] = 0 -print("Grand totals:") +print("************Grand totals************") for material, values in grand_total.items(): print( - f"{material} total: {values['grand_total']} | spent total: {values['grand_spent']} | obtained total: {values['grand_obtained']} | percentage spent: {values['grand_spent_percentage']:.2f}%" + f"{material} net: {values['grand_total']/sheet_amount} | spent total: {values['grand_spent']/sheet_amount} | obtained total: {values['grand_obtained']/sheet_amount}" ) +print("************AVERAGES************") +for material, values in grand_total.items(): + print( + f"{material} net: {round(values['grand_total']/(sheet_amount*total_files), 2)} | spent total: {round(values['grand_spent']/(sheet_amount*total_files), 2)} | obtained total: {round(values['grand_obtained']/(sheet_amount*total_files), 2)} | percentage spent: {values['grand_spent_percentage'] :.2f}%" + ) +print(f"This is equivalent to a total of an average {int(total_ores_mined/(sheet_amount*3))} mineral tiles, or {int(total_ores_mined/(sheet_amount*3*total_files))} mineral walls per round.")