Kaushik Rajan commited on
Commit
4420646
·
1 Parent(s): 85310d8

Add enhanced debugging and multiple import methods for game modules

Browse files
Files changed (1) hide show
  1. app.py +281 -246
app.py CHANGED
@@ -12,40 +12,74 @@ import sys
12
  import traceback
13
 
14
  # Add src to path for imports
15
- sys.path.append(os.path.join(os.path.dirname(__file__), 'src'))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
 
17
- # Try to import our game modules, fall back to simple versions if they fail
18
  try:
 
 
19
  from games import TicTacToeEnv, KuhnPokerEnv
 
20
  GAMES_AVAILABLE = True
21
- print("✅ Successfully imported game modules")
22
  except ImportError as e:
23
- print(f"❌ Failed to import game modules: {e}")
24
- print("📋 Traceback:", traceback.format_exc())
25
- GAMES_AVAILABLE = False
26
-
27
-
28
- def create_simple_tictactoe():
29
- """Simple TicTacToe implementation as fallback."""
30
- board = [' ' for _ in range(9)]
31
 
32
- def play_move(position, board_state):
 
 
 
 
 
 
 
 
33
  try:
34
- pos = int(position)
35
- if pos < 0 or pos > 8:
36
- return board_state, "Invalid position! Choose 0-8."
37
-
38
- # Simple game logic
39
- current_board = board_state.split('\n')[0:5] # Get board lines
40
- move_made = f"You played position {pos}"
41
-
42
- # For demo, just show the move
43
- return f"Move {pos} played!\n{board_state}", move_made
44
-
45
- except:
46
- return board_state, "Please enter a valid number 0-8"
47
-
48
- return play_move
 
 
 
 
 
 
 
 
 
49
 
50
 
51
  def create_interface():
@@ -57,245 +91,246 @@ def create_interface():
57
  if GAMES_AVAILABLE:
58
  gr.Markdown("**Demo Version** - Experience zero-sum games with AI! Full reasoning capabilities coming soon.")
59
 
60
- # Initialize game environments
61
- try:
62
- tictactoe_env = TicTacToeEnv()
63
- kuhn_env = KuhnPokerEnv()
64
- tictactoe_env.reset()
65
- kuhn_env.reset()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66
 
67
- def get_tictactoe_board():
68
- """Get current TicTacToe board as string."""
69
- board = tictactoe_env.board
70
- display = ""
71
- for row in range(3):
72
- for col in range(3):
73
- cell = board[row, col]
74
- if cell == 1:
75
- display += " X "
76
- elif cell == -1:
77
- display += " O "
 
 
 
 
 
 
 
 
 
 
 
78
  else:
79
- display += f" {row*3 + col} "
80
- if col < 2:
81
- display += "|"
82
- display += "\n"
83
- if row < 2:
84
- display += "-----------\n"
85
- return display
86
-
87
- def play_tictactoe(position):
88
- """Play a TicTacToe move."""
89
- if tictactoe_env.game_over:
90
- return get_tictactoe_board(), "Game is over! Click 'New Game' to start again.", ""
91
 
92
- try:
93
- position = int(position)
94
- if position < 0 or position > 8:
95
- return get_tictactoe_board(), "Invalid position! Choose 0-8.", ""
96
-
97
- # Human move
98
- obs, reward, terminated, truncated, info = tictactoe_env.step(position)
99
-
100
- if terminated:
101
- winner = "You" if tictactoe_env.winner == 1 else "AI" if tictactoe_env.winner == -1 else "No one"
102
- return get_tictactoe_board(), f"Game Over! {winner} won!", f"Final reward: {reward}"
103
-
104
- # AI move (random for now)
105
- if not tictactoe_env.game_over:
106
- valid_actions = tictactoe_env._get_valid_actions()
107
- if valid_actions:
108
- ai_action = random.choice(valid_actions)
109
- obs, reward, terminated, truncated, info = tictactoe_env.step(ai_action)
110
-
111
- if terminated:
112
- winner = "You" if tictactoe_env.winner == 1 else "AI" if tictactoe_env.winner == -1 else "No one"
113
- return get_tictactoe_board(), f"Game Over! {winner} won!", f"AI played position {ai_action}. Final reward: {reward}"
114
- else:
115
- return get_tictactoe_board(), f"AI played position {ai_action}. Your turn!", f"AI reasoning: Chose position {ai_action} randomly"
116
-
117
- return get_tictactoe_board(), "Your turn!", ""
118
-
119
- except ValueError:
120
- return get_tictactoe_board(), "Please enter a valid number (0-8).", ""
121
- except Exception as e:
122
- return get_tictactoe_board(), f"Error: {str(e)}", ""
123
 
124
- def reset_tictactoe():
125
- """Reset TicTacToe game."""
126
- tictactoe_env.reset()
127
- return get_tictactoe_board(), "New game started! You are X. Choose a position (0-8).", ""
 
128
 
129
- def get_kuhn_poker_state():
130
- """Get current Kuhn Poker state as string."""
131
- state = f"🃏 Your Card: {['J', 'Q', 'K'][kuhn_env.player1_card]}\n"
132
- state += f"💰 Pot: {kuhn_env.pot}\n"
133
- state += f"🎯 Current Player: {kuhn_env.current_player}\n"
134
- state += f"🔄 Betting Round: {kuhn_env.betting_round}\n"
 
 
 
 
 
 
135
 
136
- if kuhn_env.actions_history:
137
- state += "\n📋 Actions:\n"
138
- for player, action in kuhn_env.actions_history:
139
- action_name = ["Check/Call", "Bet", "Fold"][action]
140
- state += f" Player {player}: {action_name}\n"
141
 
142
- return state
143
-
144
- def play_kuhn_poker(action_name):
145
- """Play a Kuhn Poker move."""
146
- if kuhn_env.game_over:
147
- return get_kuhn_poker_state(), "Game is over! Click 'New Game' to start again.", ""
148
 
149
- try:
150
- # Map action name to action number
151
- action_map = {"Check/Call": 0, "Bet": 1, "Fold": 2}
152
- if action_name not in action_map:
153
- return get_kuhn_poker_state(), "Invalid action!", ""
154
-
155
- action = action_map[action_name]
 
 
156
 
157
- # Human move
158
- obs, reward, terminated, truncated, info = kuhn_env.step(action)
159
 
160
  if terminated:
161
  winner = "You" if kuhn_env.winner == 1 else "AI"
162
- return get_kuhn_poker_state(), f"Game Over! {winner} won! Pot: {kuhn_env.pot}", f"Your final reward: {reward}"
163
-
164
- # AI move (random for now)
165
- if not kuhn_env.game_over:
166
- valid_actions = kuhn_env._get_valid_actions()
167
- ai_action = random.choice(valid_actions)
168
- ai_action_name = ["Check/Call", "Bet", "Fold"][ai_action]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
169
 
170
- obs, reward, terminated, truncated, info = kuhn_env.step(ai_action)
 
 
 
 
 
171
 
172
- if terminated:
173
- winner = "You" if kuhn_env.winner == 1 else "AI"
174
- return get_kuhn_poker_state(), f"AI chose {ai_action_name}. Game Over! {winner} won! Pot: {kuhn_env.pot}", f"AI reasoning: Chose {ai_action_name} randomly. Your final reward: {reward}"
175
- else:
176
- return get_kuhn_poker_state(), f"AI chose {ai_action_name}. Your turn!", f"AI reasoning: Chose {ai_action_name} randomly"
177
-
178
- return get_kuhn_poker_state(), "Your turn!", ""
179
-
180
- except Exception as e:
181
- return get_kuhn_poker_state(), f"Error: {str(e)}", ""
182
-
183
- def reset_kuhn_poker():
184
- """Reset Kuhn Poker game."""
185
- kuhn_env.reset()
186
- return get_kuhn_poker_state(), "New game started! You are Player 1. Choose your action.", f"Your card: {['J', 'Q', 'K'][kuhn_env.player1_card]}"
 
 
 
 
 
 
 
 
 
 
 
 
 
187
 
188
- with gr.Tabs():
189
- # TicTacToe Tab
190
- with gr.TabItem("🎯 TicTacToe"):
191
- gr.Markdown("### Play TicTacToe against AI")
192
- gr.Markdown("You are **X** and go first. Enter a position (0-8) to make your move.")
193
-
194
- with gr.Row():
195
- with gr.Column(scale=2):
196
- ttt_board = gr.Textbox(
197
- label="Game Board",
198
- value=get_tictactoe_board(),
199
- lines=6,
200
- interactive=False,
201
- elem_id="ttt-board"
202
- )
203
-
204
- with gr.Column(scale=1):
205
- ttt_position = gr.Textbox(
206
- label="Your Move (0-8)",
207
- placeholder="Enter position number",
208
- lines=1
209
- )
210
-
211
- with gr.Row():
212
- ttt_play_btn = gr.Button("Play Move", variant="primary")
213
- ttt_reset_btn = gr.Button("New Game", variant="secondary")
214
-
215
- ttt_message = gr.Textbox(
216
- label="Game Status",
217
- value="Choose a position (0-8) to start!",
218
- lines=2,
219
- interactive=False
220
- )
221
-
222
- ttt_reasoning = gr.Textbox(
223
- label="AI Reasoning",
224
- value="AI will show its reasoning here...",
225
- lines=2,
226
- interactive=False
227
- )
228
-
229
- ttt_play_btn.click(
230
- fn=play_tictactoe,
231
- inputs=[ttt_position],
232
- outputs=[ttt_board, ttt_message, ttt_reasoning]
233
- )
234
-
235
- ttt_reset_btn.click(
236
- fn=reset_tictactoe,
237
- outputs=[ttt_board, ttt_message, ttt_reasoning]
238
- )
239
 
240
- # Kuhn Poker Tab
241
- with gr.TabItem("🃏 Kuhn Poker"):
242
- gr.Markdown("### Play Kuhn Poker against AI")
243
- gr.Markdown("Simple poker with 3 cards (J, Q, K). You are Player 1.")
244
-
245
- with gr.Row():
246
- with gr.Column(scale=2):
247
- kuhn_state = gr.Textbox(
248
- label="Game State",
249
- value=get_kuhn_poker_state(),
250
- lines=8,
251
- interactive=False
252
- )
253
-
254
- with gr.Column(scale=1):
255
- kuhn_action = gr.Dropdown(
256
- label="Your Action",
257
- choices=["Check/Call", "Bet", "Fold"],
258
- value="Check/Call"
259
- )
260
-
261
- with gr.Row():
262
- kuhn_play_btn = gr.Button("Play Action", variant="primary")
263
- kuhn_reset_btn = gr.Button("New Game", variant="secondary")
264
-
265
- kuhn_message = gr.Textbox(
266
- label="Game Status",
267
- value="Choose your action!",
268
- lines=2,
269
- interactive=False
270
- )
271
-
272
- kuhn_reasoning = gr.Textbox(
273
- label="AI Reasoning",
274
- value="AI will show its reasoning here...",
275
- lines=2,
276
- interactive=False
277
- )
278
-
279
- kuhn_play_btn.click(
280
- fn=play_kuhn_poker,
281
- inputs=[kuhn_action],
282
- outputs=[kuhn_state, kuhn_message, kuhn_reasoning]
283
- )
284
-
285
- kuhn_reset_btn.click(
286
- fn=reset_kuhn_poker,
287
- outputs=[kuhn_state, kuhn_message, kuhn_reasoning]
288
- )
289
-
290
- except Exception as e:
291
- gr.Markdown(f"⚠️ **Error initializing games:** {str(e)}")
292
- gr.Markdown("Please check the logs for more details.")
293
 
294
  else:
295
  # Fallback interface when games don't load
296
- gr.Markdown("⚠️ **Game modules could not be loaded.** Showing basic interface.")
297
  gr.Markdown("This usually happens when dependencies are still installing on HF Spaces.")
298
 
 
 
 
 
 
 
 
 
 
 
 
 
299
  # Simple demo interface
300
  with gr.Row():
301
  simple_input = gr.Textbox(label="Test Input", placeholder="Enter something...")
@@ -348,7 +383,7 @@ def create_interface():
348
  gr.Markdown("🚧 **This is a development preview.** Full SPIRAL training and reasoning capabilities will be added in the next update!")
349
  else:
350
  gr.Markdown("---")
351
- gr.Markdown("🔄 **Dependencies are loading.** Refresh in a few minutes to see the full game interface!")
352
 
353
  return demo
354
 
 
12
  import traceback
13
 
14
  # Add src to path for imports
15
+ current_dir = os.path.dirname(os.path.abspath(__file__))
16
+ src_path = os.path.join(current_dir, 'src')
17
+ sys.path.insert(0, src_path)
18
+
19
+ print(f"🔍 Current directory: {current_dir}")
20
+ print(f"🔍 Source path: {src_path}")
21
+ print(f"🔍 Python path: {sys.path[:3]}") # Show first 3 entries
22
+
23
+ # Check if src directory exists
24
+ if os.path.exists(src_path):
25
+ print(f"✅ Source directory exists: {src_path}")
26
+ games_path = os.path.join(src_path, 'games')
27
+ if os.path.exists(games_path):
28
+ print(f"✅ Games directory exists: {games_path}")
29
+ print(f"📁 Games directory contents: {os.listdir(games_path)}")
30
+ else:
31
+ print(f"❌ Games directory not found: {games_path}")
32
+ else:
33
+ print(f"❌ Source directory not found: {src_path}")
34
+
35
+ # Try multiple import approaches
36
+ GAMES_AVAILABLE = False
37
+ tictactoe_env = None
38
+ kuhn_env = None
39
 
 
40
  try:
41
+ # Method 1: Direct import from games module
42
+ print("🔄 Attempting Method 1: Direct import from games")
43
  from games import TicTacToeEnv, KuhnPokerEnv
44
+ print("✅ Method 1 successful: Imported from games module")
45
  GAMES_AVAILABLE = True
 
46
  except ImportError as e:
47
+ print(f"❌ Method 1 failed: {e}")
 
 
 
 
 
 
 
48
 
49
+ try:
50
+ # Method 2: Import from src.games
51
+ print("🔄 Attempting Method 2: Import from src.games")
52
+ from src.games import TicTacToeEnv, KuhnPokerEnv
53
+ print("✅ Method 2 successful: Imported from src.games")
54
+ GAMES_AVAILABLE = True
55
+ except ImportError as e:
56
+ print(f"❌ Method 2 failed: {e}")
57
+
58
  try:
59
+ # Method 3: Direct file imports
60
+ print("🔄 Attempting Method 3: Direct file imports")
61
+ sys.path.insert(0, games_path)
62
+ from tictactoe import TicTacToeEnv
63
+ from kuhn_poker import KuhnPokerEnv
64
+ print("✅ Method 3 successful: Direct file imports")
65
+ GAMES_AVAILABLE = True
66
+ except Exception as e:
67
+ print(f"❌ Method 3 failed: {e}")
68
+ print("📋 Full traceback:", traceback.format_exc())
69
+
70
+ if GAMES_AVAILABLE:
71
+ print("🎮 Game modules successfully imported!")
72
+ try:
73
+ # Test instantiation
74
+ tictactoe_env = TicTacToeEnv()
75
+ kuhn_env = KuhnPokerEnv()
76
+ print("✅ Game environments created successfully")
77
+ except Exception as e:
78
+ print(f"❌ Error creating game environments: {e}")
79
+ print("📋 Full traceback:", traceback.format_exc())
80
+ GAMES_AVAILABLE = False
81
+ else:
82
+ print("❌ All import methods failed - using fallback interface")
83
 
84
 
85
  def create_interface():
 
91
  if GAMES_AVAILABLE:
92
  gr.Markdown("**Demo Version** - Experience zero-sum games with AI! Full reasoning capabilities coming soon.")
93
 
94
+ def get_tictactoe_board():
95
+ """Get current TicTacToe board as string."""
96
+ board = tictactoe_env.board
97
+ display = ""
98
+ for row in range(3):
99
+ for col in range(3):
100
+ cell = board[row, col]
101
+ if cell == 1:
102
+ display += " X "
103
+ elif cell == -1:
104
+ display += " O "
105
+ else:
106
+ display += f" {row*3 + col} "
107
+ if col < 2:
108
+ display += "|"
109
+ display += "\n"
110
+ if row < 2:
111
+ display += "-----------\n"
112
+ return display
113
+
114
+ def play_tictactoe(position):
115
+ """Play a TicTacToe move."""
116
+ if tictactoe_env.game_over:
117
+ return get_tictactoe_board(), "Game is over! Click 'New Game' to start again.", ""
118
 
119
+ try:
120
+ position = int(position)
121
+ if position < 0 or position > 8:
122
+ return get_tictactoe_board(), "Invalid position! Choose 0-8.", ""
123
+
124
+ # Human move
125
+ obs, reward, terminated, truncated, info = tictactoe_env.step(position)
126
+
127
+ if terminated:
128
+ winner = "You" if tictactoe_env.winner == 1 else "AI" if tictactoe_env.winner == -1 else "No one"
129
+ return get_tictactoe_board(), f"Game Over! {winner} won!", f"Final reward: {reward}"
130
+
131
+ # AI move (random for now)
132
+ if not tictactoe_env.game_over:
133
+ valid_actions = tictactoe_env._get_valid_actions()
134
+ if valid_actions:
135
+ ai_action = random.choice(valid_actions)
136
+ obs, reward, terminated, truncated, info = tictactoe_env.step(ai_action)
137
+
138
+ if terminated:
139
+ winner = "You" if tictactoe_env.winner == 1 else "AI" if tictactoe_env.winner == -1 else "No one"
140
+ return get_tictactoe_board(), f"Game Over! {winner} won!", f"AI played position {ai_action}. Final reward: {reward}"
141
  else:
142
+ return get_tictactoe_board(), f"AI played position {ai_action}. Your turn!", f"AI reasoning: Chose position {ai_action} randomly"
 
 
 
 
 
 
 
 
 
 
 
143
 
144
+ return get_tictactoe_board(), "Your turn!", ""
145
+
146
+ except ValueError:
147
+ return get_tictactoe_board(), "Please enter a valid number (0-8).", ""
148
+ except Exception as e:
149
+ return get_tictactoe_board(), f"Error: {str(e)}", ""
150
+
151
+ def reset_tictactoe():
152
+ """Reset TicTacToe game."""
153
+ tictactoe_env.reset()
154
+ return get_tictactoe_board(), "New game started! You are X. Choose a position (0-8).", ""
155
+
156
+ def get_kuhn_poker_state():
157
+ """Get current Kuhn Poker state as string."""
158
+ state = f"🃏 Your Card: {['J', 'Q', 'K'][kuhn_env.player1_card]}\n"
159
+ state += f"💰 Pot: {kuhn_env.pot}\n"
160
+ state += f"🎯 Current Player: {kuhn_env.current_player}\n"
161
+ state += f"🔄 Betting Round: {kuhn_env.betting_round}\n"
 
 
 
 
 
 
 
 
 
 
 
 
 
162
 
163
+ if kuhn_env.actions_history:
164
+ state += "\n📋 Actions:\n"
165
+ for player, action in kuhn_env.actions_history:
166
+ action_name = ["Check/Call", "Bet", "Fold"][action]
167
+ state += f" Player {player}: {action_name}\n"
168
 
169
+ return state
170
+
171
+ def play_kuhn_poker(action_name):
172
+ """Play a Kuhn Poker move."""
173
+ if kuhn_env.game_over:
174
+ return get_kuhn_poker_state(), "Game is over! Click 'New Game' to start again.", ""
175
+
176
+ try:
177
+ # Map action name to action number
178
+ action_map = {"Check/Call": 0, "Bet": 1, "Fold": 2}
179
+ if action_name not in action_map:
180
+ return get_kuhn_poker_state(), "Invalid action!", ""
181
 
182
+ action = action_map[action_name]
 
 
 
 
183
 
184
+ # Human move
185
+ obs, reward, terminated, truncated, info = kuhn_env.step(action)
 
 
 
 
186
 
187
+ if terminated:
188
+ winner = "You" if kuhn_env.winner == 1 else "AI"
189
+ return get_kuhn_poker_state(), f"Game Over! {winner} won! Pot: {kuhn_env.pot}", f"Your final reward: {reward}"
190
+
191
+ # AI move (random for now)
192
+ if not kuhn_env.game_over:
193
+ valid_actions = kuhn_env._get_valid_actions()
194
+ ai_action = random.choice(valid_actions)
195
+ ai_action_name = ["Check/Call", "Bet", "Fold"][ai_action]
196
 
197
+ obs, reward, terminated, truncated, info = kuhn_env.step(ai_action)
 
198
 
199
  if terminated:
200
  winner = "You" if kuhn_env.winner == 1 else "AI"
201
+ return get_kuhn_poker_state(), f"AI chose {ai_action_name}. Game Over! {winner} won! Pot: {kuhn_env.pot}", f"AI reasoning: Chose {ai_action_name} randomly. Your final reward: {reward}"
202
+ else:
203
+ return get_kuhn_poker_state(), f"AI chose {ai_action_name}. Your turn!", f"AI reasoning: Chose {ai_action_name} randomly"
204
+
205
+ return get_kuhn_poker_state(), "Your turn!", ""
206
+
207
+ except Exception as e:
208
+ return get_kuhn_poker_state(), f"Error: {str(e)}", ""
209
+
210
+ def reset_kuhn_poker():
211
+ """Reset Kuhn Poker game."""
212
+ kuhn_env.reset()
213
+ return get_kuhn_poker_state(), "New game started! You are Player 1. Choose your action.", f"Your card: {['J', 'Q', 'K'][kuhn_env.player1_card]}"
214
+
215
+ with gr.Tabs():
216
+ # TicTacToe Tab
217
+ with gr.TabItem("🎯 TicTacToe"):
218
+ gr.Markdown("### Play TicTacToe against AI")
219
+ gr.Markdown("You are **X** and go first. Enter a position (0-8) to make your move.")
220
+
221
+ with gr.Row():
222
+ with gr.Column(scale=2):
223
+ ttt_board = gr.Textbox(
224
+ label="Game Board",
225
+ value=get_tictactoe_board(),
226
+ lines=6,
227
+ interactive=False,
228
+ elem_id="ttt-board"
229
+ )
230
 
231
+ with gr.Column(scale=1):
232
+ ttt_position = gr.Textbox(
233
+ label="Your Move (0-8)",
234
+ placeholder="Enter position number",
235
+ lines=1
236
+ )
237
 
238
+ with gr.Row():
239
+ ttt_play_btn = gr.Button("Play Move", variant="primary")
240
+ ttt_reset_btn = gr.Button("New Game", variant="secondary")
241
+
242
+ ttt_message = gr.Textbox(
243
+ label="Game Status",
244
+ value="Choose a position (0-8) to start!",
245
+ lines=2,
246
+ interactive=False
247
+ )
248
+
249
+ ttt_reasoning = gr.Textbox(
250
+ label="AI Reasoning",
251
+ value="AI will show its reasoning here...",
252
+ lines=2,
253
+ interactive=False
254
+ )
255
+
256
+ ttt_play_btn.click(
257
+ fn=play_tictactoe,
258
+ inputs=[ttt_position],
259
+ outputs=[ttt_board, ttt_message, ttt_reasoning]
260
+ )
261
+
262
+ ttt_reset_btn.click(
263
+ fn=reset_tictactoe,
264
+ outputs=[ttt_board, ttt_message, ttt_reasoning]
265
+ )
266
 
267
+ # Kuhn Poker Tab
268
+ with gr.TabItem("🃏 Kuhn Poker"):
269
+ gr.Markdown("### Play Kuhn Poker against AI")
270
+ gr.Markdown("Simple poker with 3 cards (J, Q, K). You are Player 1.")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
271
 
272
+ with gr.Row():
273
+ with gr.Column(scale=2):
274
+ kuhn_state = gr.Textbox(
275
+ label="Game State",
276
+ value=get_kuhn_poker_state(),
277
+ lines=8,
278
+ interactive=False
279
+ )
280
+
281
+ with gr.Column(scale=1):
282
+ kuhn_action = gr.Dropdown(
283
+ label="Your Action",
284
+ choices=["Check/Call", "Bet", "Fold"],
285
+ value="Check/Call"
286
+ )
287
+
288
+ with gr.Row():
289
+ kuhn_play_btn = gr.Button("Play Action", variant="primary")
290
+ kuhn_reset_btn = gr.Button("New Game", variant="secondary")
291
+
292
+ kuhn_message = gr.Textbox(
293
+ label="Game Status",
294
+ value="Choose your action!",
295
+ lines=2,
296
+ interactive=False
297
+ )
298
+
299
+ kuhn_reasoning = gr.Textbox(
300
+ label="AI Reasoning",
301
+ value="AI will show its reasoning here...",
302
+ lines=2,
303
+ interactive=False
304
+ )
305
+
306
+ kuhn_play_btn.click(
307
+ fn=play_kuhn_poker,
308
+ inputs=[kuhn_action],
309
+ outputs=[kuhn_state, kuhn_message, kuhn_reasoning]
310
+ )
311
+
312
+ kuhn_reset_btn.click(
313
+ fn=reset_kuhn_poker,
314
+ outputs=[kuhn_state, kuhn_message, kuhn_reasoning]
315
+ )
 
 
 
 
 
 
 
 
 
316
 
317
  else:
318
  # Fallback interface when games don't load
319
+ gr.Markdown("⚠️ **Game modules could not be loaded.** Showing diagnostic information.")
320
  gr.Markdown("This usually happens when dependencies are still installing on HF Spaces.")
321
 
322
+ # Show diagnostic info
323
+ gr.Markdown("### 🔍 Diagnostic Information:")
324
+ gr.Markdown(f"- Current directory: `{current_dir}`")
325
+ gr.Markdown(f"- Source path: `{src_path}`")
326
+ gr.Markdown(f"- Source directory exists: `{os.path.exists(src_path)}`")
327
+
328
+ if os.path.exists(src_path):
329
+ games_path = os.path.join(src_path, 'games')
330
+ gr.Markdown(f"- Games directory exists: `{os.path.exists(games_path)}`")
331
+ if os.path.exists(games_path):
332
+ gr.Markdown(f"- Games directory contents: `{os.listdir(games_path)}`")
333
+
334
  # Simple demo interface
335
  with gr.Row():
336
  simple_input = gr.Textbox(label="Test Input", placeholder="Enter something...")
 
383
  gr.Markdown("🚧 **This is a development preview.** Full SPIRAL training and reasoning capabilities will be added in the next update!")
384
  else:
385
  gr.Markdown("---")
386
+ gr.Markdown("🔄 **Dependencies are loading.** Check the diagnostic info above and refresh in a few minutes!")
387
 
388
  return demo
389