Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -13,9 +13,9 @@ game_mechanics = ["Action Queue", "Action Retrieval", "Campaign / Battle Card Dr
|
|
13 |
"Solo / Solitaire Game", "Storytelling", "Variable Player Powers"]
|
14 |
|
15 |
# Define a function to generate random values for each game mechanic
|
16 |
-
def generate_values():
|
17 |
-
health_points = np.random.randint(50, 100, size=
|
18 |
-
coins = np.random.randint(10, 50, size=
|
19 |
return {"HealthPoints": health_points, "Coins": coins}
|
20 |
|
21 |
# Define the Streamlit app
|
@@ -24,14 +24,15 @@ def app():
|
|
24 |
st.write("This app displays a Treemap chart of game mechanics.")
|
25 |
|
26 |
# Generate the data for the chart
|
27 |
-
|
|
|
28 |
data = pd.DataFrame({
|
29 |
-
"category": ["Category 1"] *
|
30 |
"mechanic": game_mechanics,
|
31 |
"value": list(values.values()),
|
32 |
"HealthPoints": values["HealthPoints"],
|
33 |
"Coins": values["Coins"],
|
34 |
-
"description": ["Description"] *
|
35 |
})
|
36 |
data["value"] = data["value"].apply(lambda x: sum(x))
|
37 |
|
@@ -47,4 +48,4 @@ def app():
|
|
47 |
st.markdown(href, unsafe_allow_html=True)
|
48 |
|
49 |
if __name__ == '__main__':
|
50 |
-
app()
|
|
|
13 |
"Solo / Solitaire Game", "Storytelling", "Variable Player Powers"]
|
14 |
|
15 |
# Define a function to generate random values for each game mechanic
|
16 |
+
def generate_values(n):
|
17 |
+
health_points = np.random.randint(50, 100, size=n)
|
18 |
+
coins = np.random.randint(10, 50, size=n)
|
19 |
return {"HealthPoints": health_points, "Coins": coins}
|
20 |
|
21 |
# Define the Streamlit app
|
|
|
24 |
st.write("This app displays a Treemap chart of game mechanics.")
|
25 |
|
26 |
# Generate the data for the chart
|
27 |
+
n = len(game_mechanics)
|
28 |
+
values = generate_values(n)
|
29 |
data = pd.DataFrame({
|
30 |
+
"category": ["Category 1"] * n,
|
31 |
"mechanic": game_mechanics,
|
32 |
"value": list(values.values()),
|
33 |
"HealthPoints": values["HealthPoints"],
|
34 |
"Coins": values["Coins"],
|
35 |
+
"description": ["Description"] * n
|
36 |
})
|
37 |
data["value"] = data["value"].apply(lambda x: sum(x))
|
38 |
|
|
|
48 |
st.markdown(href, unsafe_allow_html=True)
|
49 |
|
50 |
if __name__ == '__main__':
|
51 |
+
app()
|