0Learn commited on
Commit
433ba72
·
verified ·
1 Parent(s): 5d8f2d4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +410 -122
app.py CHANGED
@@ -1,135 +1,423 @@
1
  import gradio as gr
2
  import random
3
-
4
- # Question bank with 50 questions, each with 4 options
5
- question_bank = [
6
- {"question": "What does the Gen Z term 'No cap' mean?", "options": ["No lie", "No truth", "No joke", "No fun"], "answer": "No lie"},
7
- {"question": "What does the 80's term 'Rad' mean?", "options": ["Cool", "Uncool", "Happy", "Sad"], "answer": "Cool"},
8
- {"question": "What does the Millennial term 'Adulting' mean?", "options": ["Acting like an adult", "Acting like a kid", "Being responsible", "Being irresponsible"], "answer": "Acting like an adult"},
9
- {"question": "What does the Gen Z term 'Simp' mean?", "options": ["A simple person", "A smart person", "A kind person", "A foolish person"], "answer": "A foolish person"},
10
- {"question": "What does the 90's term 'Talk to the hand' mean?", "options": ["I'm not listening", "I'm listening", "I'm busy", "I'm available"], "answer": "I'm not listening"},
11
- {"question": "What does the Millennial term 'Slay' mean?", "options": ["To do poorly", "To do well", "To try hard", "To give up"], "answer": "To do well"},
12
- {"question": "What does the Gen Z term 'Ghost' mean?", "options": ["To leave suddenly", "To stay forever", "To come back", "To never leave"], "answer": "To leave suddenly"},
13
- {"question": "What does the 70's term 'Freak out' mean?", "options": ["To dance wildly", "To sing loudly", "To lose control", "To stay calm"], "answer": "To lose control"},
14
- {"question": "What does the Millennial term 'Lowkey' mean?", "options": ["Secretly", "Openly", "Quietly", "Loudly"], "answer": "Secretly"},
15
- {"question": "What does the Gen Z term 'Highkey' mean?", "options": ["Obviously", "Secretly", "Quietly", "Loudly"], "answer": "Obviously"},
16
- {"question": "What does the 60's term 'Groovy' mean?", "options": ["Cool", "Uncool", "Happy", "Sad"], "answer": "Cool"},
17
- {"question": "What does the Millennial term 'Shook' mean?", "options": ["Surprised", "Unimpressed", "Excited", "Bored"], "answer": "Surprised"},
18
- {"question": "What does the Gen Z term 'Savage' mean?", "options": ["Cruel", "Kind", "Funny", "Sad"], "answer": "Cruel"},
19
- {"question": "What does the 50's term 'Cool cat' mean?", "options": ["A cool person", "A mean person", "A happy person", "A sad person"], "answer": "A cool person"},
20
- {"question": "What does the Gen Z term 'Lit' mean?", "options": ["Exciting", "Boring", "Happy", "Sad"], "answer": "Exciting"},
21
- {"question": "What does the Millennial term 'Yaaas' mean?", "options": ["Yes", "No", "Maybe", "I don't know"], "answer": "Yes"},
22
- {"question": "What does the Gen Z term 'No tea, no shade' mean?", "options": ["No gossip, no insult", "No news, no rumors", "No secrets, no lies", "No fun, no joke"], "answer": "No gossip, no insult"},
23
- {"question": "What does the 90's term 'As if!' mean?", "options": ["I don't believe you", "I believe you", "I'm joking", "I'm serious"], "answer": "I don't believe you"},
24
- {"question": "What does the Millennial term 'Salty' mean?", "options": ["Bitter", "Sweet", "Sour", "Umami"], "answer": "Bitter"},
25
- {"question": "What does the Gen Z term 'Shooketh' mean?", "options": ["Surprised", "Unimpressed", "Excited", "Bored"], "answer": "Surprised"},
26
- {"question": "What does the 80's term 'Gag me with a spoon' mean?", "options": ["I'm disgusted", "I'm happy", "I'm sad", "I'm angry"], "answer": "I'm disgusted"},
27
- {"question": "What does the Gen Z term 'Simpsons' mean?", "options": ["A funny show", "A boring show", "A cartoon", "A reality show"], "answer": "A funny show"},
28
- {"question": "What does the 50's term 'Cruisin' for a bruisin'' mean?", "options": ["Looking for trouble", "Looking for fun", "Looking for love", "Looking for friendship"], "answer": "Looking for trouble"},
29
- {"question": "What does the 80's term 'Gnarly' mean?", "options": ["Cool", "Uncool", "Happy", "Sad"], "answer": "Cool"},
30
- {"question": "What does the 70's term 'Freaky' mean?", "options": ["Weird", "Normal", "Happy", "Sad"], "answer": "Weird"},
31
- {"question": "What does the Millennial term 'Turn up' mean?", "options": ["To have fun", "To be quiet", "To go home", "To stay in"], "answer": "To have fun"},
32
- {"question": "What does the 60's term 'Vibes' mean?", "options": ["Good atmosphere", "Bad atmosphere", "Happy feelings", "Sad feelings"], "answer": "Good atmosphere"},
33
- {"question": "What does the Millennial term 'Yikes' mean?", "options": ["I'm scared", "I'm happy", "I'm sad", "I'm angry"], "answer": "I'm scared"},
34
- {"question": "What does the Gen Z term 'Bet' mean?", "options": ["Okay", "Not okay", "Maybe", "I don't know"], "answer": "Okay"},
35
- {"question": "What does the 80's term 'Bogus' mean?", "options": ["Bad", "Good", "Happy", "Sad"], "answer": "Bad"},
36
- {"question": "What does the Gen Z term 'Tea' mean?", "options": ["Gossip", "News", "Rumors", "Secrets"], "answer": "Gossip"},
37
- {"question": "What does the 70's term 'Stay cool' mean?", "options": ["Stay calm", "Stay happy", "Stay sad", "Stay angry"], "answer": "Stay calm"},
38
- {"question": "What does the Millennial term 'Turnt' mean?", "options": ["Exciting", "Boring", "Happy", "Sad"], "answer": "Exciting"},
39
- {"question": "What does the 60's term 'Far out' mean?", "options": ["Cool", "Uncool", "Happy", "Sad"], "answer": "Cool"},
40
- {"question": "What does the Millennial term 'Lowkey/Highkey' mean?", "options": ["Secretly/Openly", "Quietly/Loudly", "Happy/Sad", "Angry/Calm"], "answer": "Secretly/Openly"},
41
- {"question": "What does the 50's term 'Square' mean?", "options": ["A cool person", "A mean person", "A happy person", "An uncool person"], "answer": "An uncool person"},
42
- {"question": "What does the Millennial term 'Slayyed' mean?", "options": ["To do poorly", "To do well", "To try hard", "To give up"], "answer": "To do well"},
43
- {"question": "What does the Gen Z term 'Cap' mean?", "options": ["To lie", "To tell the truth", "To joke", "To be serious"], "answer": "To lie"},
44
- {"question": "What does the Millennial term 'Sis' mean?", "options": ["A friend", "A family member", "A stranger", "A enemy"], "answer": "A friend"},
45
- {"question": "What does the 90's term 'Word' mean?", "options": ["True", "False", "Maybe", "I don't know"], "answer": "True"},
46
- {"question": "What does the Gen Z term 'Mid' mean?", "options": ["Good", "Bad", "Okay", "Awful"], "answer": "Bad"},
47
- {"question": "What does the 80's term 'Psyche' mean?", "options": ["To trick", "To help", "To joke", "To be serious"], "answer": "To trick"},
48
- {"question": "What does the Millennial term 'Tea time' mean?", "options": ["Time for gossip", "Time for news", "Time for rumors", "Time for secrets"], "answer": "Time for gossip"},
49
- {"question": "What does the 70's term 'Dig it' mean?", "options": ["To understand", "To not understand", "To like", "To dislike"], "answer": "To understand"},
50
- {"question": "What does the Gen Z term 'No drama' mean?", "options": ["No conflict", "No fun", "No friends", "No life"], "answer": "No conflict"},
51
- {"question": "What does the 60's term 'Hang loose' mean?", "options": ["To relax", "To worry", "To be happy", "To be sad"], "answer": "To relax"},
52
- {"question": "What does the Millennial term 'Shade' mean?", "options": ["To insult", "To compliment", "To joke", "To be serious"], "answer": "To insult"},
53
- {"question": "What does the 50's term 'Righteous' mean?", "options": ["Good", "Bad", "Happy", "Sad"], "answer": "Good"},
54
- {"question": "What does the Gen Z term 'Salty' mean?", "options": ["Bitter", "Sweet", "Sour", "Umami"], "answer": "Bitter"},
55
- {"question": "What does the 80's term 'Harshing the mellow' mean?", "options": ["To ruin the fun", "To enhance the fun", "To not affect the fun", "To leave the fun"], "answer": "To ruin the fun"},
56
- {"question": "What does the Millennial term 'Yikes' mean?", "options": ["I'm scared", "I'm happy", "I'm sad", "I'm angry"], "answer": "I'm scared"},
57
- {"question": "What does the 70's term 'Freak flag' mean?", "options": ["To express oneself", "To hide oneself", "To be different", "To be normal"], "answer": "To express oneself"}
58
- ]
59
-
60
- # Help lines
61
- help_lines = {
62
- "50:50": lambda question: [option for option in question["options"] if option != question["answer"]][:2],
63
- "Skip": None,
64
- "Clue": lambda question: f"{question['answer']} is the correct answer."
65
- }
66
 
67
  # Game state
68
  game_state = {
 
69
  "current_question": 0,
70
- "score": 0,
71
- "safe_spots": [5, 10],
72
- "help_lines_used": {"50:50": False, "Skip": False, "Clue": False}
 
 
73
  }
74
- def get_next_question():
75
- print("Getting next question...")
76
- if game_state["current_question"] < len(question_bank):
77
- print("Returning question:", question_bank[game_state["current_question"]])
78
- return question_bank[game_state["current_question"]]
79
- else:
80
- print("Returning congratulations message.")
81
- return {"question": "Congratulations, you've won!", "options": [], "answer": ""}
82
-
83
- def update_game_state():
84
- print("Updating game state...")
85
- game_state["current_question"] += 1
86
- print("Loading next question...")
87
- return get_next_question()
88
-
89
-
90
- def check_answer(answer):
91
- if answer == question_bank[game_state["current_question"]]["answer"]:
92
- game_state["score"] += 1
93
- game_state["current_question"] += 1
94
- return "Correct!"
95
- else:
96
- return "Incorrect!"
97
-
98
- def use_help_line(help_line):
99
- if help_line == "50:50":
100
- game_state["help_lines_used"]["50:50"] = True
101
- return help_lines["50:50"](question_bank[game_state["current_question"]])
102
- elif help_line == "Skip":
103
- game_state["help_lines_used"]["Skip"] = True
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
104
  game_state["current_question"] += 1
105
- return None
106
- elif help_line == "Clue":
107
- game_state["help_lines_used"]["Clue"] = True
108
- return help_lines["Clue"](question_bank[game_state["current_question"]])
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
109
 
110
  with gr.Blocks() as demo:
111
- question = gr.Textbox(label="Question")
112
- options = gr.Radio(label="Options")
113
- submit = gr.Button("Submit")
114
- help_line_50_50 = gr.Button("50:50")
115
- help_line_skip = gr.Button("Skip")
116
- help_line_clue = gr.Button("Clue")
117
- score = gr.Number(label="Score")
118
- result = gr.Textbox(label="Result")
119
-
120
- submit.click(check_answer, inputs=[options], outputs=[result])
121
- input_block = gr.Textbox(label="Input", value="50:50", visible=False)
122
- help_line_50_50.click(use_help_line, inputs=[input_block], outputs=[options])
123
- skip_button = gr.Button("Skip")
124
- help_line_skip.click(use_help_line, inputs=[skip_button], outputs=[question])
125
- clue_button = gr.Button("Clue")
126
- help_line_clue.click(use_help_line, inputs=[clue_button], outputs=[result])
127
- demo.load(get_next_question, inputs=[], outputs=[question, options, score])
128
-
129
- def update_game_state():
130
- game_state["current_question"] += 1
131
- return get_next_question()
132
 
133
- demo.load(update_game_state, inputs=[], outputs=[question, options, score], every=1)
 
 
 
 
 
134
 
135
  demo.launch()
 
1
  import gradio as gr
2
  import random
3
+ import time
4
+ import threading
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
 
6
  # Game state
7
  game_state = {
8
+ "game_started": False,
9
  "current_question": 0,
10
+ "money": 0,
11
+ "lifelines": {"fifty_fifty": True, "skip": True, "clue": True},
12
+ "safe_levels": [5, 10],
13
+ "timer": 60,
14
+ "timer_active": False
15
  }
16
+
17
+ # Updated Question bank
18
+ questions = [
19
+ {
20
+ "question": "What does the Gen Z term 'No cap' mean?",
21
+ "options": ["A. No lie", "B. No truth", "C. No joke", "D. No fun"],
22
+ "correct": "A",
23
+ "generation": "Gen Z"
24
+ },
25
+ {
26
+ "question": "What does the 80's term 'Rad' mean?",
27
+ "options": ["A. Cool", "B. Uncool", "C. Happy", "D. Sad"],
28
+ "correct": "A",
29
+ "generation": "80s"
30
+ },
31
+ {
32
+ "question": "What does the Millennial term 'Adulting' mean?",
33
+ "options": ["A. Acting like an adult", "B. Acting like a kid", "C. Being responsible", "D. Being irresponsible"],
34
+ "correct": "A",
35
+ "generation": "Millennial"
36
+ },
37
+ {
38
+ "question": "What does the Gen Z term 'Simp' mean?",
39
+ "options": ["A. A simple person", "B. A smart person", "C. A kind person", "D. A foolish person"],
40
+ "correct": "D",
41
+ "generation": "Gen Z"
42
+ },
43
+ {
44
+ "question": "What does the 90's term 'Talk to the hand' mean?",
45
+ "options": ["A. I'm not listening", "B. I'm listening", "C. I'm busy", "D. I'm available"],
46
+ "correct": "A",
47
+ "generation": "90s"
48
+ },
49
+ {
50
+ "question": "What does the Millennial term 'Slay' mean?",
51
+ "options": ["A. To do poorly", "B. To do well", "C. To try hard", "D. To give up"],
52
+ "correct": "B",
53
+ "generation": "Millennial"
54
+ },
55
+ {
56
+ "question": "What does the Gen Z term 'Ghost' mean?",
57
+ "options": ["A. To leave suddenly", "B. To stay forever", "C. To come back", "D. To never leave"],
58
+ "correct": "A",
59
+ "generation": "Gen Z"
60
+ },
61
+ {
62
+ "question": "What does the 70's term 'Freak out' mean?",
63
+ "options": ["A. To dance wildly", "B. To sing loudly", "C. To lose control", "D. To stay calm"],
64
+ "correct": "C",
65
+ "generation": "70s"
66
+ },
67
+ {
68
+ "question": "What does the Millennial term 'Lowkey' mean?",
69
+ "options": ["A. Secretly", "B. Openly", "C. Quietly", "D. Loudly"],
70
+ "correct": "A",
71
+ "generation": "Millennial"
72
+ },
73
+ {
74
+ "question": "What does the Gen Z term 'Highkey' mean?",
75
+ "options": ["A. Obviously", "B. Secretly", "C. Quietly", "D. Loudly"],
76
+ "correct": "A",
77
+ "generation": "Gen Z"
78
+ },
79
+ {
80
+ "question": "What does the 60's term 'Groovy' mean?",
81
+ "options": ["A. Cool", "B. Uncool", "C. Happy", "D. Sad"],
82
+ "correct": "A",
83
+ "generation": "60s"
84
+ },
85
+ {
86
+ "question": "What does the Millennial term 'Shook' mean?",
87
+ "options": ["A. Surprised", "B. Unimpressed", "C. Excited", "D. Bored"],
88
+ "correct": "A",
89
+ "generation": "Millennial"
90
+ },
91
+ {
92
+ "question": "What does the Gen Z term 'Savage' mean?",
93
+ "options": ["A. Cruel", "B. Kind", "C. Funny", "D. Sad"],
94
+ "correct": "A",
95
+ "generation": "Gen Z"
96
+ },
97
+ {
98
+ "question": "What does the 50's term 'Cool cat' mean?",
99
+ "options": ["A. A cool person", "B. A mean person", "C. A happy person", "D. A sad person"],
100
+ "correct": "A",
101
+ "generation": "50s"
102
+ },
103
+ {
104
+ "question": "What does the Gen Z term 'Lit' mean?",
105
+ "options": ["A. Exciting", "B. Boring", "C. Happy", "D. Sad"],
106
+ "correct": "A",
107
+ "generation": "Gen Z"
108
+ },
109
+ {
110
+ "question": "What does the Millennial term 'Yaaas' mean?",
111
+ "options": ["A. Yes", "B. No", "C. Maybe", "D. I don't know"],
112
+ "correct": "A",
113
+ "generation": "Millennial"
114
+ },
115
+ {
116
+ "question": "What does the Gen Z term 'No tea, no shade' mean?",
117
+ "options": ["A. No gossip, no insult", "B. No news, no rumors", "C. No secrets, no lies", "D. No fun, no joke"],
118
+ "correct": "A",
119
+ "generation": "Gen Z"
120
+ },
121
+ {
122
+ "question": "What does the 90's term 'As if!' mean?",
123
+ "options": ["A. I don't believe you", "B. I believe you", "C. I'm joking", "D. I'm serious"],
124
+ "correct": "A",
125
+ "generation": "90s"
126
+ },
127
+ {
128
+ "question": "What does the Gen Z term 'Shooketh' mean?",
129
+ "options": ["A. Surprised", "B. Unimpressed", "C. Excited", "D. Bored"],
130
+ "correct": "A",
131
+ "generation": "Gen Z"
132
+ },
133
+ {
134
+ "question": "What does the 80's term 'Gag me with a spoon' mean?",
135
+ "options": ["A. I'm disgusted", "B. I'm happy", "C. I'm sad", "D. I'm angry"],
136
+ "correct": "A",
137
+ "generation": "80s"
138
+ },
139
+ {
140
+ "question": "What does the 50's term 'Cruisin' for a bruisin'' mean?",
141
+ "options": ["A. Looking for trouble", "B. Looking for fun", "C. Looking for love", "D. Looking for friendship"],
142
+ "correct": "A",
143
+ "generation": "50s"
144
+ },
145
+ {
146
+ "question": "What does the 80's term 'Gnarly' mean?",
147
+ "options": ["A. Cool", "B. Uncool", "C. Happy", "D. Sad"],
148
+ "correct": "A",
149
+ "generation": "80s"
150
+ },
151
+ {
152
+ "question": "What does the 70's term 'Freaky' mean?",
153
+ "options": ["A. Weird", "B. Normal", "C. Happy", "D. Sad"],
154
+ "correct": "A",
155
+ "generation": "70s"
156
+ },
157
+ {
158
+ "question": "What does the Millennial term 'Turn up' mean?",
159
+ "options": ["A. To have fun", "B. To be quiet", "C. To go home", "D. To stay in"],
160
+ "correct": "A",
161
+ "generation": "Millennial"
162
+ },
163
+ {
164
+ "question": "What does the 60's term 'Vibes' mean?",
165
+ "options": ["A. Good atmosphere", "B. Bad atmosphere", "C. Happy feelings", "D. Sad feelings"],
166
+ "correct": "A",
167
+ "generation": "60s"
168
+ },
169
+ {
170
+ "question": "What does the Gen Z term 'Bet' mean?",
171
+ "options": ["A. Okay", "B. Not okay", "C. Maybe", "D. I don't know"],
172
+ "correct": "A",
173
+ "generation": "Gen Z"
174
+ },
175
+ {
176
+ "question": "What does the 80's term 'Bogus' mean?",
177
+ "options": ["A. Bad", "B. Good", "C. Happy", "D. Sad"],
178
+ "correct": "A",
179
+ "generation": "80s"
180
+ },
181
+ {
182
+ "question": "What does the Gen Z term 'Tea' mean?",
183
+ "options": ["A. Gossip", "B. News", "C. Rumors", "D. Secrets"],
184
+ "correct": "A",
185
+ "generation": "Gen Z"
186
+ },
187
+ {
188
+ "question": "What does the 70's term 'Stay cool' mean?",
189
+ "options": ["A. Stay calm", "B. Stay happy", "C. Stay sad", "D. Stay angry"],
190
+ "correct": "A",
191
+ "generation": "70s"
192
+ },
193
+ {
194
+ "question": "What does the Millennial term 'Turnt' mean?",
195
+ "options": ["A. Exciting", "B. Boring", "C. Happy", "D. Sad"],
196
+ "correct": "A",
197
+ "generation": "Millennial"
198
+ },
199
+ {
200
+ "question": "What does the 60's term 'Far out' mean?",
201
+ "options": ["A. Cool", "B. Uncool", "C. Happy", "D. Sad"],
202
+ "correct": "A",
203
+ "generation": "60s"
204
+ },
205
+ {
206
+ "question": "What does the Millennial term 'Lowkey/Highkey' mean?",
207
+ "options": ["A. Secretly/Openly", "B. Quietly/Loudly", "C. Happy/Sad", "D. Angry/Calm"],
208
+ "correct": "A",
209
+ "generation": "Millennial"
210
+ },
211
+ {
212
+ "question": "What does the 50's term 'Square' mean?",
213
+ "options": ["A. A cool person", "B. A mean person", "C. A happy person", "D. An uncool person"],
214
+ "correct": "D",
215
+ "generation": "50s"
216
+ },
217
+ {
218
+ "question": "What does the Gen Z term 'Cap' mean?",
219
+ "options": ["A. To lie", "B. To tell the truth", "C. To joke", "D. To be serious"],
220
+ "correct": "A",
221
+ "generation": "Gen Z"
222
+ },
223
+ {
224
+ "question": "What does the Millennial term 'Sis' mean?",
225
+ "options": ["A. A friend", "B. A family member", "C. A stranger", "D. An enemy"],
226
+ "correct": "A",
227
+ "generation": "Millennial"
228
+ },
229
+ {
230
+ "question": "What does the 90's term 'Word' mean?",
231
+ "options": ["A. True", "B. False", "C. Maybe", "D. I don't know"],
232
+ "correct": "A",
233
+ "generation": "90s"
234
+ },
235
+ {
236
+ "question": "What does the Gen Z term 'Mid' mean?",
237
+ "options": ["A. Good", "B. Bad", "C. Okay", "D. Awful"],
238
+ "correct": "B",
239
+ "generation": "Gen Z"
240
+ },
241
+ {
242
+ "question": "What does the 80's term 'Psyche' mean?",
243
+ "options": ["A. To trick", "B. To help", "C. To joke", "D. To be serious"],
244
+ "correct": "A",
245
+ "generation": "80s"
246
+ },
247
+ {
248
+ "question": "What does the Millennial term 'Tea time' mean?",
249
+ "options": ["A. Time for gossip", "B. Time for news", "C. Time for rumors", "D. Time for secrets"],
250
+ "correct": "A",
251
+ "generation": "Millennial"
252
+ },
253
+ {
254
+ "question": "What does the 70's term 'Dig it' mean?",
255
+ "options": ["A. To understand", "B. To not understand", "C. To like", "D. To dislike"],
256
+ "correct": "A",
257
+ "generation": "70s"
258
+ },
259
+ {
260
+ "question": "What does the Gen Z term 'No drama' mean?",
261
+ "options": ["A. No conflict", "B. No fun", "C. No friends", "D. No life"],
262
+ "correct": "A",
263
+ "generation": "Gen Z"
264
+ },
265
+ {
266
+ "question": "What does the 60's term 'Hang loose' mean?",
267
+ "options": ["A. To relax", "B. To worry", "C. To be happy", "D. To be sad"],
268
+ "correct": "A",
269
+ "generation": "60s"
270
+ },
271
+ {
272
+ "question": "What does the Millennial term 'Shade' mean?",
273
+ "options": ["A. To insult", "B. To compliment", "C. To joke", "D. To be serious"],
274
+ "correct": "A",
275
+ "generation": "Millennial"
276
+ },
277
+ {
278
+ "question": "What does the 50's term 'Righteous' mean?",
279
+ "options": ["A. Good", "B. Bad", "C. Happy", "D. Sad"],
280
+ "correct": "A",
281
+ "generation": "50s"
282
+ },
283
+ {
284
+ "question": "What does the 80's term 'Harshing the mellow' mean?",
285
+ "options": ["A. To ruin the fun", "B. To enhance the fun", "C. To not affect the fun", "D. To leave the fun"],
286
+ "correct": "A",
287
+ "generation": "80s"
288
+ },
289
+ {
290
+ "question": "What does the 70's term 'Freak flag' mean?",
291
+ "options": ["A. To express oneself", "B. To hide oneself", "C. To be different", "D. To be normal"],
292
+ "correct": "A",
293
+ "generation": "70s"
294
+ }
295
+ ]
296
+
297
+ # Rest of the code remains the same...
298
+
299
+ # (Include all the previous functions and Gradio interface code here)
300
+
301
+ demo.launch()
302
+
303
+ # Money levels
304
+ money_levels = [100, 200, 300, 500, 1000, 2000, 4000, 8000, 16000, 32000, 64000, 125000, 250000, 500000, 1000000]
305
+
306
+ # Timer prompts
307
+ timer_prompts = [
308
+ "Tick tock! 50 seconds left. No pressure, but also... lots of pressure!",
309
+ "40 seconds remaining. Is that your final answer? (No, seriously, is it?)",
310
+ "30 seconds on the clock! Time flies when you're trying to be a millionaire!",
311
+ "20 seconds left! Don't let the clock psyche you out!",
312
+ "Only 10 seconds remaining! Quick, phone a fr... oh wait, wrong lifeline!",
313
+ ]
314
+
315
+ def start_timer():
316
+ game_state["timer"] = 60
317
+ game_state["timer_active"] = True
318
+ while game_state["timer"] > 0 and game_state["timer_active"]:
319
+ time.sleep(1)
320
+ game_state["timer"] -= 1
321
+
322
+ def get_bot_response(message):
323
+ message = message.lower().strip()
324
+
325
+ if not game_state["game_started"]:
326
+ if "start game" in message or "play game" in message:
327
+ game_state["game_started"] = True
328
+ game_state["current_question"] = 0
329
+ game_state["money"] = 0
330
+ game_state["lifelines"] = {"fifty_fifty": True, "skip": True, "clue": True}
331
+ return "Welcome to Who Wants to Be a Millionaire: Slang Edition! Let's start with the first question. Type 'ready' when you're set to go!"
332
+ else:
333
+ return "I'm a Who Wants to Be a Millionaire: Slang Edition game bot. Type 'start game' to begin playing!"
334
+
335
+ if message == "ready":
336
+ question = questions[game_state["current_question"]]
337
+ options = "\n".join(question["options"])
338
+ threading.Thread(target=start_timer).start()
339
+ return f"Question {game_state['current_question'] + 1} for ${money_levels[game_state['current_question']]}:\n{question['question']}\n{options}\nLifelines available: {', '.join([k for k, v in game_state['lifelines'].items() if v])}\nYou have 60 seconds. Go!"
340
+
341
+ if message in ["a", "b", "c", "d"]:
342
+ game_state["timer_active"] = False
343
+ question = questions[game_state["current_question"]]
344
+ if message.upper() == question["correct"]:
345
+ game_state["money"] = money_levels[game_state["current_question"]]
346
+ game_state["current_question"] += 1
347
+ if game_state["current_question"] == len(questions):
348
+ game_state["game_started"] = False
349
+ return f"Congratulations! You've won the grand prize of $1,000,000! Game over. Type 'start game' to play again."
350
+ elif game_state["current_question"] in game_state["safe_levels"]:
351
+ return f"Correct! You've reached a safe level of ${game_state['money']}. Type 'ready' for the next question."
352
+ else:
353
+ return f"Correct! You've won ${game_state['money']}. Type 'ready' for the next question or 'quit' to leave with your winnings."
354
+ else:
355
+ game_state["game_started"] = False
356
+ safe_money = max([money_levels[level - 1] for level in game_state["safe_levels"] if level <= game_state["current_question"]], default=0)
357
+ return f"I'm sorry, that's incorrect. The correct answer was {question['correct']}. You leave with ${safe_money}. Game over. Type 'start game' to play again."
358
+
359
+ if message == "quit":
360
+ game_state["timer_active"] = False
361
+ game_state["game_started"] = False
362
+ return f"You've decided to quit. You leave with ${game_state['money']}. Thanks for playing! Type 'start game' to play again."
363
+
364
+ if message == "fifty_fifty" and game_state["lifelines"]["fifty_fifty"]:
365
+ game_state["lifelines"]["fifty_fifty"] = False
366
+ question = questions[game_state["current_question"]]
367
+ correct = question["correct"]
368
+ options = [opt[0].upper() for opt in question["options"]]
369
+ options.remove(correct)
370
+ remove = random.sample(options, 2)
371
+ new_options = [opt for opt in question["options"] if opt[0].upper() not in remove]
372
+ return f"Fifty-Fifty used. Remaining options:\n" + "\n".join(new_options)
373
+
374
+ if message == "skip" and game_state["lifelines"]["skip"]:
375
+ game_state["lifelines"]["skip"] = False
376
  game_state["current_question"] += 1
377
+ game_state["timer_active"] = False
378
+ return "Skip used. Moving to the next question. Type 'ready' to see it."
379
+
380
+ if message == "clue" and game_state["lifelines"]["clue"]:
381
+ game_state["lifelines"]["clue"] = False
382
+ question = questions[game_state["current_question"]]
383
+ correct = question["correct"]
384
+ options = [opt[0].upper() for opt in question["options"]]
385
+ options.remove(correct)
386
+ remove = random.choice(options)
387
+ new_options = [opt for opt in question["options"] if opt[0].upper() != remove]
388
+ return f"Clue used. One wrong option removed. Remaining options:\n" + "\n".join(new_options)
389
+
390
+ return "I don't understand that command. Type 'ready' for the question, A/B/C/D to answer, or use a lifeline (fifty_fifty/skip/clue)."
391
+
392
+ def chat(message, history):
393
+ history = history or []
394
+ history.append((message, ""))
395
+ bot_message = get_bot_response(message)
396
+ history.append((message, bot_message))
397
+ return history, ""
398
+
399
+ def timer_update(history):
400
+ if game_state["timer_active"]:
401
+ if game_state["timer"] == 0:
402
+ game_state["timer_active"] = False
403
+ game_state["game_started"] = False
404
+ safe_money = max([money_levels[level - 1] for level in game_state["safe_levels"] if level <= game_state["current_question"]], default=0)
405
+ return history + [("System", f"Time's up! You've run out of time. You leave with ${safe_money}. Game over. Type 'start game' to play again.")]
406
+ elif game_state["timer"] % 10 == 0:
407
+ prompt_index = 5 - (game_state["timer"] // 10)
408
+ return history + [("System", timer_prompts[prompt_index])]
409
+ return history
410
 
411
  with gr.Blocks() as demo:
412
+ chatbot = gr.Chatbot()
413
+ msg = gr.Textbox(label="Type your message here", placeholder="Enter your message...")
414
+ clear = gr.Button("Clear")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
415
 
416
+ msg.submit(chat, inputs=[msg, chatbot], outputs=[chatbot, msg])
417
+ clear.click(lambda: None, None, chatbot, queue=False)
418
+
419
+ timer = gr.Number(value=60, label="Time Remaining", every=1)
420
+ timer.change(timer_update, inputs=[chatbot], outputs=[chatbot])
421
+ demo.load(lambda: game_state["timer"], None, timer, every=1)
422
 
423
  demo.launch()