delete app.py
Browse files
app.py
DELETED
@@ -1,97 +0,0 @@
|
|
1 |
-
import streamlit as st
|
2 |
-
import random
|
3 |
-
from collections import Counter
|
4 |
-
|
5 |
-
# Set up the Streamlit app
|
6 |
-
st.set_page_config(page_title="Bầu Cua Tôm Cá", layout="centered")
|
7 |
-
st.title("Bầu Cua Tôm Cá")
|
8 |
-
|
9 |
-
# Add a header image
|
10 |
-
st.image("https://example.com/header_image.jpg", use_column_width=True)
|
11 |
-
|
12 |
-
# Set font and colors
|
13 |
-
st.markdown(
|
14 |
-
"""
|
15 |
-
<style>
|
16 |
-
.stButton>button {
|
17 |
-
font-size: 18px;
|
18 |
-
background-color: #FF5733;
|
19 |
-
color: #FFFFFF;
|
20 |
-
border-radius: 10px;
|
21 |
-
padding: 10px 20px;
|
22 |
-
}
|
23 |
-
.stSelectbox, .stRadio {
|
24 |
-
font-size: 18px;
|
25 |
-
color: #333333;
|
26 |
-
}
|
27 |
-
.stText {
|
28 |
-
font-size: 18px;
|
29 |
-
color: #333333;
|
30 |
-
}
|
31 |
-
.stApp {
|
32 |
-
background-color: #F5F5F5;
|
33 |
-
}
|
34 |
-
</style>
|
35 |
-
""",
|
36 |
-
unsafe_allow_html=True
|
37 |
-
)
|
38 |
-
|
39 |
-
# UI elements
|
40 |
-
shake_count = st.selectbox("Số lần lắc", ["1000", "50", "100", "500"])
|
41 |
-
shake_info = st.empty()
|
42 |
-
result_label = st.empty()
|
43 |
-
|
44 |
-
dice_faces = ["Bầu", "Cua", "Tôm", "Cá", "Gà", "Nai"]
|
45 |
-
default_faces = ["Cá", "Gà", "Nai"]
|
46 |
-
selected_faces = []
|
47 |
-
|
48 |
-
for i in range(3):
|
49 |
-
selected_faces.append(st.radio(f"Chọn mặt {i+1}", dice_faces, index=dice_faces.index(default_faces[i])))
|
50 |
-
|
51 |
-
# Opposite and adjacent faces (not used in Streamlit version)
|
52 |
-
opposite_faces = {
|
53 |
-
"Bầu": "Cua",
|
54 |
-
"Cua": "Bầu",
|
55 |
-
"Nai": "Tôm",
|
56 |
-
"Tôm": "Nai",
|
57 |
-
"Gà": "Cá",
|
58 |
-
"Cá": "Gà"
|
59 |
-
}
|
60 |
-
|
61 |
-
adjacent_faces = {
|
62 |
-
"Bầu": ["Tôm", "Gà", "Nai", "Cá"],
|
63 |
-
"Cá": ["Bầu", "Nai", "Cua", "Tôm"],
|
64 |
-
"Gà": ["Bầu", "Tôm", "Cua", "Nai"],
|
65 |
-
"Tôm": ["Bầu", "Cá", "Cua", "Gà"],
|
66 |
-
"Nai": ["Bầu", "Gà", "Cua", "Cá"],
|
67 |
-
"Cua": ["Tôm", "Cá", "Nai", "Gà"]
|
68 |
-
}
|
69 |
-
|
70 |
-
def predict_result():
|
71 |
-
outcomes = ["Bầu", "Cua", "Tôm", "Cá", "Gà", "Nai"]
|
72 |
-
shake_count_int = int(shake_count)
|
73 |
-
|
74 |
-
if len(selected_faces) == 3:
|
75 |
-
results = [random.choice(outcomes) for _ in range(shake_count_int)]
|
76 |
-
result_counts = Counter(results)
|
77 |
-
sorted_results = sorted(result_counts.items(), key=lambda x: x[1], reverse=True)
|
78 |
-
|
79 |
-
result_text = "Kết quả:\n"
|
80 |
-
for outcome, count in sorted_results:
|
81 |
-
result_text += f"{outcome}: {count} ({count/shake_count_int:.2%})\n"
|
82 |
-
|
83 |
-
result_label.text(result_text)
|
84 |
-
shake_info.text(f"Số lần lắc: {shake_count}")
|
85 |
-
else:
|
86 |
-
result_label.text("Vui lòng chọn 3 mặt đầu tiên.")
|
87 |
-
|
88 |
-
def reset_results():
|
89 |
-
result_label.text("Kết quả: ")
|
90 |
-
shake_info.text("Số lần lắc: 0")
|
91 |
-
|
92 |
-
# Buttons
|
93 |
-
if st.button("Lắc"):
|
94 |
-
predict_result()
|
95 |
-
|
96 |
-
if st.button("Reset"):
|
97 |
-
reset_results()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|