Kaushik Rajan commited on
Commit
a3e1550
ยท
1 Parent(s): 5c7fb25

fix(ui): Implement 3x3 grid layout for Tic-Tac-Toe board

Browse files
Files changed (1) hide show
  1. app.py +28 -8
app.py CHANGED
@@ -103,7 +103,26 @@ def generate_reasoning(prompt):
103
  def create_interface():
104
  """Create the main Gradio interface."""
105
 
106
- with gr.Blocks(title="SPIRAL: Interactive Reasoning Game Simulator", theme=gr.themes.Soft()) as demo:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
107
  gr.Markdown("# ๐ŸŽฎ SPIRAL: Interactive Reasoning Game Simulator")
108
  gr.Markdown("Play TicTacToe against an AI, see its step-by-step reasoning, and learn how it thinks!")
109
 
@@ -226,13 +245,14 @@ def create_interface():
226
  gr.Markdown("### Play TicTacToe against AI\nYou are โŒ (X) and go first. Click on a square to make your move.")
227
 
228
  with gr.Column():
229
- board_buttons = []
230
- for i in range(3):
231
- with gr.Row():
232
- for j in range(3):
233
- pos = i * 3 + j
234
- button = gr.Button("", elem_id=f"ttt-cell-{pos}")
235
- board_buttons.append(button)
 
236
 
237
  with gr.Row():
238
  ttt_reset_btn = gr.Button("New Game", variant="secondary")
 
103
  def create_interface():
104
  """Create the main Gradio interface."""
105
 
106
+ # Custom CSS to style the TicTacToe board
107
+ css = """
108
+ #ttt-grid {
109
+ display: grid;
110
+ grid-template-columns: repeat(3, 1fr);
111
+ grid-template-rows: repeat(3, 1fr);
112
+ gap: 5px;
113
+ max-width: 300px;
114
+ margin: auto;
115
+ }
116
+ #ttt-grid .gr-button {
117
+ aspect-ratio: 1 / 1;
118
+ font-size: 24px !important;
119
+ font-weight: bold;
120
+ height: 100px !important;
121
+ min-width: 100px !important;
122
+ }
123
+ """
124
+
125
+ with gr.Blocks(title="SPIRAL: Interactive Reasoning Game Simulator", theme=gr.themes.Soft(), css=css) as demo:
126
  gr.Markdown("# ๐ŸŽฎ SPIRAL: Interactive Reasoning Game Simulator")
127
  gr.Markdown("Play TicTacToe against an AI, see its step-by-step reasoning, and learn how it thinks!")
128
 
 
245
  gr.Markdown("### Play TicTacToe against AI\nYou are โŒ (X) and go first. Click on a square to make your move.")
246
 
247
  with gr.Column():
248
+ with gr.Box(elem_id="ttt-grid"):
249
+ board_buttons = []
250
+ for i in range(3):
251
+ with gr.Row():
252
+ for j in range(3):
253
+ pos = i * 3 + j
254
+ button = gr.Button("", elem_id=f"ttt-cell-{pos}")
255
+ board_buttons.append(button)
256
 
257
  with gr.Row():
258
  ttt_reset_btn = gr.Button("New Game", variant="secondary")