lucadipalma commited on
Commit
e3285d7
ยท
1 Parent(s): 1fde086

new how to play page

Browse files
app.py CHANGED
@@ -6,7 +6,7 @@ start_mcp_servers()
6
  from support.log_manager import logger
7
  from support.game_settings import custom_header
8
  from support.settings import SERVER_PORT
9
- from pages import home, play, stats
10
  from support.style.css import final_css
11
  from support.game_settings import JS
12
 
@@ -19,6 +19,9 @@ with gr.Blocks(fill_width=True, title="Agentic Codenames", css=final_css, js=JS)
19
  with gr.Tab("๐Ÿ  Home", id="home_id_tab", elem_classes="tab_btn"):
20
  home.demo.render()
21
 
 
 
 
22
  with gr.Tab("๐ŸŽฎ Play", id="play_id_tab", elem_classes="tab_btn"):
23
  play.demo.render()
24
 
@@ -34,4 +37,4 @@ if __name__ == "__main__":
34
  server_port=SERVER_PORT,
35
  allowed_paths=["assets"],
36
  favicon_path='assets/favicon.ico'
37
- )
 
6
  from support.log_manager import logger
7
  from support.game_settings import custom_header
8
  from support.settings import SERVER_PORT
9
+ from pages import home, play, stats, how_to_play
10
  from support.style.css import final_css
11
  from support.game_settings import JS
12
 
 
19
  with gr.Tab("๐Ÿ  Home", id="home_id_tab", elem_classes="tab_btn"):
20
  home.demo.render()
21
 
22
+ with gr.Tab("โ“ How to Play", id="how_to_play_id_tab", elem_classes="tab_btn"):
23
+ how_to_play.demo.render()
24
+
25
  with gr.Tab("๐ŸŽฎ Play", id="play_id_tab", elem_classes="tab_btn"):
26
  play.demo.render()
27
 
 
37
  server_port=SERVER_PORT,
38
  allowed_paths=["assets"],
39
  favicon_path='assets/favicon.ico'
40
+ )
pages/how_to_play.py ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ from support.game_settings import EXAMPLE_GAME_RULES_HTML
4
+
5
+
6
+ # Game board description HTML
7
+ GAME_BOARD_HTML = """
8
+ <div style="display: flex; flex-direction: column; gap: 20px;">
9
+ <div><h3>๐ŸŽฏ Example Game Board</h3></div>
10
+ <div>
11
+ <p>Below is a sample Codenames board showing the <strong>Boss's view</strong> with color-coded words:</p>
12
+ <ul>
13
+ <li><strong style="color: #dc3545;">Red squares</strong> = Red team's words</li>
14
+ <li><strong style="color: #0d6efd;">Blue squares</strong> = Blue team's words</li>
15
+ <li><strong style="color: #6c757d;">Beige squares</strong> = Neutral words (innocent bystanders)</li>
16
+ <li><strong style="color: #212529;">Black square</strong> = Killer word (instant loss if touched!)</li>
17
+ </ul>
18
+ <p><strong>Remember:</strong> Only the <strong>Boss</strong> sees these colors. The <strong>Captain</strong> and <strong>Players</strong> only see the words!</p>
19
+ </div>
20
+ </div>
21
+ """
22
+
23
+ with gr.Blocks(fill_width=True) as demo:
24
+ # Rules section with HTML
25
+ with gr.Row(elem_id="row_description", equal_height=True):
26
+ with gr.Column():
27
+ gr.HTML(GAME_BOARD_HTML, elem_id="game_board_description")
28
+ gr.Image(
29
+ "assets/example.png",
30
+ label="Game Board (Boss's View)",
31
+ show_label=True,
32
+ height=450,
33
+ elem_id="example_game_board_img",
34
+ )
35
+ with gr.Column():
36
+ gr.HTML(EXAMPLE_GAME_RULES_HTML, elem_id="rules_content")
37
+
38
+ if __name__ == "__main__":
39
+ demo.launch()
support/game_settings.py CHANGED
@@ -42,6 +42,87 @@ APP_DESCRIPTION_HTML = """
42
  </div>
43
  """
44
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
  GAME_RULES_HTML = """
46
  <div class="rules-content">
47
  <div class="rules-carousel-container">
@@ -531,6 +612,7 @@ custom_header = """
531
  <div class="navbar-title">๐Ÿ•ต๏ธ Agentic Codenames Arena</div>
532
  <div class="navbar-links">
533
  <a href="#" class="nav-link active" data-tab-id="home_id">Home</a>
 
534
  <a href="#" class="nav-link" data-tab-id="play_id">Play</a>
535
  <a href="#" class="nav-link" data-tab-id="stats_id">Stats</a>
536
  </div>
 
42
  </div>
43
  """
44
 
45
+ # Game rules HTML
46
+ EXAMPLE_GAME_RULES_HTML = """
47
+ <div style="display: flex; flex-direction: column; gap: 20px;">
48
+ <div>
49
+ <h3>๐Ÿ‘ฅ Team Roles</h3>
50
+ <p>Each team has three members with distinct responsibilities:</p>
51
+ <ul>
52
+ <li><strong>1 Boss</strong> ๐ŸŽฏ: The only player who can see the color-coded board. Provides clues to guide the team.</li>
53
+ <li><strong>1 Captain</strong> ๐Ÿงญ: Coordinates team reasoning, synthesizes suggestions, and makes final word selections.</li>
54
+ <li><strong>2 Players</strong> ๐Ÿ’ญ: Collaborate with the Captain, propose interpretations and associations.</li>
55
+ </ul>
56
+
57
+ <h3>๐Ÿ“‹ What Each Role Sees</h3>
58
+ <ul>
59
+ <li><strong>Boss:</strong> Sees the full color-coded board (like the image on the left) showing which words belong to their team, neutral words, and the killer word.</li>
60
+ <li><strong>Captain & Players:</strong> Only see the words <em>without colors</em> โ€” they must guess based on the Boss's clues!</li>
61
+ </ul>
62
+
63
+ <h3>๐ŸŽฎ How a Turn Works</h3>
64
+ <h4>1๏ธโƒฃ Boss Gives a Clue</h4>
65
+ <p>The Red Boss (seeing the board) might say:</p>
66
+ <blockquote style="background: #f8f9fa; padding: 10px; border-left: 4px solid #dc3545;">
67
+ <strong>"Atmosphere: 3"</strong>
68
+ </blockquote>
69
+ <p>This clue suggests 3 red words are related to "atmosphere". Looking at the board, the Boss is thinking of:</p>
70
+ <ul>
71
+ <li><strong>AIR</strong> (part of the atmosphere)</li>
72
+ <li><strong>SPACE</strong> (beyond the atmosphere)</li>
73
+ <li><strong>SOUND</strong> (travels through air, part of the atmosphere)</li>
74
+ </ul>
75
+ <p><em>โš ๏ธ Important: The clue must be ONE word and ONE number. The number indicates how many words relate to that clue.</em></p>
76
+
77
+ <h4>2๏ธโƒฃ Team Discussion</h4>
78
+ <p>The Captain and Players discuss without seeing the colors:</p>
79
+ <ul>
80
+ <li><strong>Player 1:</strong> "AIR feels like the safest bet โ€” it's literally the atmosphere."</li>
81
+ <li><strong>Player 2:</strong> "SPACE could connect because it's outside the atmosphere."</li>
82
+ <li><strong>Captain:</strong> "SOUND could also fit โ€” it travels through air. Let's prioritize those three."</li>
83
+ </ul>
84
+
85
+ <h4>3๏ธโƒฃ Captain Makes Final Selection</h4>
86
+ <p>The Captain decides which words to touch, in order:</p>
87
+ <ol>
88
+ <li>AIR โœ… (Red - Correct!)</li>
89
+ <li>SPACE โœ… (Red - Correct!)</li>
90
+ <li>SOUND โœ… (Red - Correct!)</li>
91
+ </ol>
92
+ <p>The team can stop after any correct guess or continue up to the number given (+1 bonus from previous turns if applicable).</p>
93
+
94
+ <h3>โš ๏ธ Mistakes to Avoid</h3>
95
+ <ul>
96
+ <li>If the team guesses <strong>STAFF</strong> (black - killer word), the game <strong>immediately ends</strong> and they <strong>lose</strong>!</li>
97
+ <li>If they guess <strong>WALL</strong> (blue - opponent's word), their turn ends and the Blue team gets that word.</li>
98
+ <li>If they guess <strong>SATURN</strong> (beige - neutral), their turn simply ends.</li>
99
+ </ul>
100
+
101
+ <h3>๐Ÿ† Winning the Game</h3>
102
+ <p>The game ends when:</p>
103
+ <ul>
104
+ <li>โœ… <strong>A team finds all their colored words</strong> โ†’ That team wins!</li>
105
+ <li>โŒ <strong>A team touches the killer word (STAFF)</strong> โ†’ That team loses immediately!</li>
106
+ </ul>
107
+
108
+ <h3>๐Ÿ’ก Strategy Tips</h3>
109
+ <p><strong>For the Boss:</strong></p>
110
+ <ul>
111
+ <li>Try to link multiple words with creative clues</li>
112
+ <li>Avoid clues that might lead to the killer word or opponent's words</li>
113
+ <li>Think about word associations your team might make</li>
114
+ </ul>
115
+ <p><strong>For Captain & Players:</strong></p>
116
+ <ul>
117
+ <li>Discuss all possible interpretations</li>
118
+ <li>Consider which words are risky</li>
119
+ <li>Don't be afraid to stop early to avoid the killer word</li>
120
+ <li>The Captain has final say, but should listen to all suggestions</li>
121
+ </ul>
122
+ </div>
123
+ </div>
124
+ """
125
+
126
  GAME_RULES_HTML = """
127
  <div class="rules-content">
128
  <div class="rules-carousel-container">
 
612
  <div class="navbar-title">๐Ÿ•ต๏ธ Agentic Codenames Arena</div>
613
  <div class="navbar-links">
614
  <a href="#" class="nav-link active" data-tab-id="home_id">Home</a>
615
+ <a href="#" class="nav-link" data-tab-id="how_to_play_id">How to play</a>
616
  <a href="#" class="nav-link" data-tab-id="play_id">Play</a>
617
  <a href="#" class="nav-link" data-tab-id="stats_id">Stats</a>
618
  </div>
support/style/css.py CHANGED
@@ -117,12 +117,17 @@ nav.tabs button.selected:hover {
117
  }
118
 
119
  [data-tab-id="home_id_tab"],
 
120
  [data-tab-id="play_id_tab"],
121
  [data-tab-id="stats_id_tab"] {
122
  display: none !important;
123
  }
124
 
125
 
 
 
 
 
126
 
127
  @media (max-width: 768px) {
128
  nav.tabs {
 
117
  }
118
 
119
  [data-tab-id="home_id_tab"],
120
+ [data-tab-id="how_to_play_id_tab"],
121
  [data-tab-id="play_id_tab"],
122
  [data-tab-id="stats_id_tab"] {
123
  display: none !important;
124
  }
125
 
126
 
127
+ #game_board_description{
128
+ flex-grow: 0 !important;
129
+ }
130
+
131
 
132
  @media (max-width: 768px) {
133
  nav.tabs {