Spaces:
kooldark
/
No application file

kooldark commited on
Commit
0f09eb0
·
verified ·
1 Parent(s): 3278973

delete app1.py

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