Skip to content

Commit

Permalink
visualize battle log from csv
Browse files Browse the repository at this point in the history
  • Loading branch information
fe-art committed Sep 18, 2024
1 parent 229806f commit 9ce35eb
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 1 deletion.
Empty file.
4 changes: 4 additions & 0 deletions clashroyalebuildabot/bot_stats/battle_log.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
timestamp,win,trophies



32 changes: 32 additions & 0 deletions clashroyalebuildabot/bot_stats/chart_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import matplotlib.pyplot as plt
import pandas as pd


def draw_chart_from_battle_log():
data = pd.read_csv("battle_log.csv")

data["timestamp"] = pd.to_datetime(data["timestamp"])

data["result"] = data["win"]

plt.figure(figsize=(10, 5))
plt.xlabel("Timestamp")
plt.xticks(rotation=45)

plt.plot(data["timestamp"], data["trophies"], color="orange", marker="x")
plt.ylabel("Trophies")
plt.title("Battle Results and Trophies Over Time")
plt.legend(["Trophies"])

# add lines for win and loss
for i in range(len(data)):
if data["result"][i] == 1:
plt.axvline(x=data["timestamp"][i], color="green", alpha=0.5)
else:
plt.axvline(x=data["timestamp"][i], color="red", alpha=0.5)

plt.grid()
plt.show()


draw_chart_from_battle_log()
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ dependencies = [
"flake8==7.0.0",
"isort==5.13.2",
"pylint==3.1.0",

"matplotlib>=3.9.2"
]
[project.optional-dependencies]
cpu = [
Expand Down

0 comments on commit 9ce35eb

Please sign in to comment.