olivercareyncl commited on
Commit
3eb09de
·
verified ·
1 Parent(s): 6b8cbf3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +44 -27
app.py CHANGED
@@ -11,39 +11,57 @@ state = {
11
  "hints_used": 0
12
  }
13
 
14
- # Enhanced Storyline with Historical Context
15
  story_intro = """
16
  ## 🐦 The Tyne Bridge Pigeon Rebellion
17
 
18
- It is **present day**, and Newcastle is in **full-blown crisis**.
 
19
 
20
- **Pigeon Dave**, the **only bird in history to ever receive a salary**, was meant to be the guest of honor at Newcastle’s **prestigious heritage ceremony**.
21
-
22
- But **disaster has struck**—**Pigeon Dave has vanished without a trace**!
23
 
24
  The **Lord Mayor is preparing his speech**, the **media is swarming**, and the **city’s reputation is on the line**. If Pigeon Dave is not found **within the next hour**, the ceremony will be an **absolute disaster**.
 
25
 
26
- ### 📜 **Historical Context**
 
 
27
 
28
- The **Tyne Bridge**, completed in **1928**, is an architectural symbol of Newcastle. During its construction, a peculiar legend emerged—a pigeon, affectionately known as **Pigeon Dave**, became a fixture among the workers. The laborers swore that he arrived **daily**, observed the progress, and even took **breaks** like a regular employee.
29
 
30
- Eventually, as a **good-humored gesture**, the city put **Pigeon Dave on the payroll**, making him the **first and only paid pigeon in British history**. For decades, his tale was forgotten, buried under layers of bureaucratic paperwork—until now.
 
31
 
32
- **Your Mission:** Track down Pigeon Dave, unravel the conspiracy, and ensure Newcastle’s most famous bird gets the **recognition he deserves!**
 
 
33
  """
34
 
35
- # New Set of More Challenging & Historically Rich Puzzles
 
 
 
 
 
 
 
 
 
 
 
 
 
36
  puzzles = [
37
- {"clue": "The first sighting: A cryptic message was found in a Greggs receipt near the Quayside.\nIt reads: ‘A legend once stood where the river bends, under the gaze of steel giants.’\nWhere should you investigate first?", "answer": "Tyne Bridge"},
38
- {"clue": "The Tyne Bridge was inspired by another, more famous British bridge. Which one?", "answer": "Sydney Harbour Bridge"},
39
- {"clue": "A street performer near the bridge claims to have seen Dave, but they will only talk if you answer:\nWhat is the only letter that does **not** appear in any UK city name?", "answer": "J"},
40
- {"clue": "Following a trail of suspicious breadcrumbs, you find a **mysterious coded note**.\nThe note reads: ‘NUFCTHR33L3G3ND’\nWhat does it refer to?", "answer": "Alan Shearer"},
41
- {"clue": "A bartender at a pub in the Bigg Market swears he saw a pigeon causing chaos at **closing time**.\nTo unlock the next clue, solve this riddle:\n‘Though I have no feet, I leave tracks behind;\nYou follow me wherever I go,\nYet you cannot touch me or hold me.\nWhat am I?’", "answer": "Shadow"},
42
- {"clue": "The search leads you to **Jesmond**, where Dave was last spotted.\nA cryptic text message appears on your phone: ‘**Check the relic that guards wisdom.**’\nWhere should you look?", "answer": "Library"},
43
- {"clue": "Inside the library, an **ancient-looking book falls from the shelf**.\nThe inside cover has a single question written in ink:\n‘**The more you take, the more you leave behind. What am I?**’", "answer": "Footsteps"},
44
- {"clue": "A librarian mentions that a **local historian** has vital information about Pigeon Dave.\nBut first, they want you to answer:\nWhat is the **oldest building in Newcastle still standing?**", "answer": "Castle Keep"},
45
- {"clue": "The historian reveals that Dave may be at his old haunt—**his favorite secret hideout from the 1920s**.\nIf Pigeon Dave worked on the Tyne Bridge construction, where would he have hidden?", "answer": "High Level Bridge"},
46
- {"clue": "At the **High Level Bridge**, you finally spot Dave! But he refuses to return unless you prove you are truly worthy.\nTo complete your mission, answer this final challenge:\n‘What was Newcastle’s original name during Roman times?’", "answer": "Pons Aelius"}
47
  ]
48
 
49
  # Timer and Scoring System
@@ -54,7 +72,7 @@ def start_game():
54
  state["found_dave"] = False
55
  state["start_time"] = time.time()
56
  state["hints_used"] = 0
57
- return story_intro + "\n\n**First Clue:** " + puzzles[0]["clue"]
58
 
59
  def get_hint():
60
  if state["progress"] < len(puzzles):
@@ -65,14 +83,11 @@ def get_hint():
65
  def game_logic(user_input):
66
  if state["progress"] < len(puzzles):
67
  current_puzzle = puzzles[state["progress"]]
68
- if user_input.strip().lower() == current_puzzle["answer"].strip().lower():
69
  state["progress"] += 1
70
  state["clues_solved"] += 1
71
  if state["progress"] == len(puzzles):
72
- state["found_dave"] = True
73
- elapsed_time = time.time() - state["start_time"]
74
- score = max(100 - (elapsed_time // 10) - (state["hints_used"] * 5), 0)
75
- return f"🎉 You found Pigeon Dave! Newcastle is saved! 🐦\nFinal Score: {int(score)}", None
76
  return f"✅ Correct! {puzzles[state['progress']]['clue']}", None
77
  else:
78
  return "❌ Not quite! Try again.", None
@@ -84,9 +99,11 @@ def reset_game():
84
  # Gradio Interface
85
  with gr.Blocks() as app:
86
  gr.Markdown(story_intro)
 
 
87
 
88
  game_output = gr.Textbox(label="Game Status", interactive=False, value=start_game())
89
- user_input = gr.Textbox(label="Your Answer")
90
  submit_btn = gr.Button("Submit Answer")
91
  hint_btn = gr.Button("Get a Hint")
92
  reset_btn = gr.Button("Reset Game")
 
11
  "hints_used": 0
12
  }
13
 
14
+ # Enhanced Storyline with Historical Context and Plot Twists
15
  story_intro = """
16
  ## 🐦 The Tyne Bridge Pigeon Rebellion
17
 
18
+ ### **The Crisis**
19
+ Newcastle is in **full-blown crisis**.
20
 
21
+ The city's **most famous pigeon**, Pigeon Dave, is missing. As the **only bird in history to receive a salary**, he was meant to be the guest of honor at Newcastle’s **prestigious heritage ceremony**.
 
 
22
 
23
  The **Lord Mayor is preparing his speech**, the **media is swarming**, and the **city’s reputation is on the line**. If Pigeon Dave is not found **within the next hour**, the ceremony will be an **absolute disaster**.
24
+ """
25
 
26
+ history_section = """
27
+ ### **A Look Back in Time**
28
+ The **Tyne Bridge**, completed in **1928**, is one of Newcastle’s most iconic landmarks. During its construction, a peculiar legend emerged—a pigeon, affectionately known as **Pigeon Dave**, became a fixture among the workers.
29
 
30
+ Every morning, Dave **arrived like clockwork**, perched on scaffolding, and “supervised” the laborers. He became such an integral part of the team that, as a **good-humored gesture**, the city **put him on the payroll**, making him the **first and only paid pigeon in British history**.
31
 
32
+ His story, once well-known, faded into obscurity—until today. **Now, it’s your job to track him down.**
33
+ """
34
 
35
+ mission_section = """
36
+ ### **Your Mission**
37
+ Unravel the conspiracy, follow the clues, and ensure Newcastle’s most famous bird **gets the recognition he deserves!**
38
  """
39
 
40
+ # Introducing Plot Twists & Multiple Endings
41
+ plot_twists = [
42
+ "Pigeon Dave was **kidnapped by a secret underground pigeon racing ring** operating in Newcastle! Find the hideout and negotiate his release!",
43
+ "Dave wasn’t kidnapped—**he was accidentally removed from city records due to a clerical error**. You must battle Newcastle’s bureaucracy to reinstate him!",
44
+ "Dave doesn’t want to return—he’s **gone into retirement** in a cozy Jesmond garden. Convince him to come back for one last grand public appearance!"
45
+ ]
46
+
47
+ endings = [
48
+ "🏅 **Best Ending:** Dave arrives just in time, delivers a ceremonial ‘coo,’ and gets a **golden bird bath** in his honor!",
49
+ "🥈 **Neutral Ending:** A **random pigeon fills in for Dave**, the crowd doesn’t notice, and the ceremony proceeds. Meanwhile, Dave watches from a rooftop, nodding approvingly.",
50
+ "🥉 **Bad Ending:** The Mayor replaces the event with a **two-hour PowerPoint on council budgets.** Newcastle mourns the lost legend."
51
+ ]
52
+
53
+ # New Set of More Challenging & Historically Rich Puzzles (Multiple Choice Format)
54
  puzzles = [
55
+ {"clue": "A cryptic message was found in a Greggs receipt near the Quayside.\nWhere should you investigate first?", "options": ["Grey’s Monument", "Tyne Bridge", "St. James’ Park"], "answer": "Tyne Bridge"},
56
+ {"clue": "The Tyne Bridge was inspired by another, more famous British bridge. Which one?", "options": ["Tower Bridge", "Sydney Harbour Bridge", "Brooklyn Bridge"], "answer": "Sydney Harbour Bridge"},
57
+ {"clue": "What is the only letter that does **not** appear in any UK city name?", "options": ["J", "Q", "X"], "answer": "J"},
58
+ {"clue": "Following a trail of breadcrumbs, you find a mysterious coded note reading: ‘NUFCTHR33L3G3ND’.\nWhat does it refer to?", "options": ["Kevin Keegan", "Alan Shearer", "Bobby Robson"], "answer": "Alan Shearer"},
59
+ {"clue": "A pub in Bigg Market reports a pigeon causing chaos at **closing time**. Solve this riddle:\n‘Though I have no feet, I leave tracks behind; You follow me wherever I go, Yet you cannot touch me or hold me. What am I?’", "options": ["Wind", "Shadow", "Echo"], "answer": "Shadow"},
60
+ {"clue": "A cryptic text message appears on your phone: ‘**Check the relic that guards wisdom.**’\nWhere should you look?", "options": ["Library", "Museum", "Cathedral"], "answer": "Library"},
61
+ {"clue": "Inside the library, an **ancient-looking book falls from the shelf**. The inside cover has a single question written in ink:\n‘**The more you take, the more you leave behind. What am I?**’", "options": ["Memories", "Footsteps", "Secrets"], "answer": "Footsteps"},
62
+ {"clue": "What is the **oldest building in Newcastle still standing?**", "options": ["Theatre Royal", "Castle Keep", "The Sage"], "answer": "Castle Keep"},
63
+ {"clue": "If Pigeon Dave worked on the Tyne Bridge construction, where would he have hidden?", "options": ["High Level Bridge", "The Baltic", "Central Station"], "answer": "High Level Bridge"},
64
+ {"clue": "What was Newcastle’s original name during Roman times?", "options": ["Hadrian’s Wall", "Pons Aelius", "Vicus"], "answer": "Pons Aelius"}
65
  ]
66
 
67
  # Timer and Scoring System
 
72
  state["found_dave"] = False
73
  state["start_time"] = time.time()
74
  state["hints_used"] = 0
75
+ return story_intro
76
 
77
  def get_hint():
78
  if state["progress"] < len(puzzles):
 
83
  def game_logic(user_input):
84
  if state["progress"] < len(puzzles):
85
  current_puzzle = puzzles[state["progress"]]
86
+ if user_input == current_puzzle["answer"]:
87
  state["progress"] += 1
88
  state["clues_solved"] += 1
89
  if state["progress"] == len(puzzles):
90
+ return random.choice(endings), None
 
 
 
91
  return f"✅ Correct! {puzzles[state['progress']]['clue']}", None
92
  else:
93
  return "❌ Not quite! Try again.", None
 
99
  # Gradio Interface
100
  with gr.Blocks() as app:
101
  gr.Markdown(story_intro)
102
+ gr.Markdown(history_section)
103
+ gr.Markdown(mission_section)
104
 
105
  game_output = gr.Textbox(label="Game Status", interactive=False, value=start_game())
106
+ user_input = gr.Radio(label="Your Answer", choices=[""], interactive=True)
107
  submit_btn = gr.Button("Submit Answer")
108
  hint_btn = gr.Button("Get a Hint")
109
  reset_btn = gr.Button("Reset Game")