DarshanScripts commited on
Commit
bbb09fe
·
verified ·
1 Parent(s): bedc00b

Upload stratego\web\components\game_history.py with huggingface_hub

Browse files
stratego//web//components//game_history.py ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Move history display component"""
2
+ import streamlit as st
3
+
4
+
5
+ def render_game_history(game_controller, limit=None):
6
+ """Display all game move history (or last N moves if limit specified)
7
+
8
+ Args:
9
+ game_controller: GameController instance
10
+ limit: Max moves to show. None = show all moves
11
+ """
12
+ if not game_controller:
13
+ return
14
+
15
+ moves = game_controller.get_move_history_display(limit)
16
+
17
+ if not moves:
18
+ st.info("No moves yet")
19
+ return
20
+
21
+ # Show in expandable container if many moves
22
+ if len(moves) > 20:
23
+ with st.expander(f"Move History ({len(moves)} total moves)", expanded=False):
24
+ # Show in columns for better layout with many moves
25
+ col1, col2 = st.columns(2)
26
+ for i, move in enumerate(moves):
27
+ if i % 2 == 0:
28
+ with col1:
29
+ st.caption(f"**{i+1}.** {move}")
30
+ else:
31
+ with col2:
32
+ st.caption(f"**{i+1}.** {move}")
33
+ else:
34
+ st.subheader(f"Move History ({len(moves)} moves)")
35
+ cols = st.columns(2)
36
+ for i, move in enumerate(moves):
37
+ col_idx = i % 2
38
+ with cols[col_idx]:
39
+ st.caption(f"**{i+1}.** {move}")
40
+
41
+
42
+ def render_game_summary(game_controller):
43
+ """Display game summary info"""
44
+ if not game_controller:
45
+ return
46
+
47
+ col1, col2, col3 = st.columns(3)
48
+
49
+ with col1:
50
+ st.metric("Turn", game_controller.get_turn_count())
51
+
52
+ with col2:
53
+ player = "Your turn" if game_controller.is_human_turn() else "AI thinking"
54
+ st.metric("Current", player)
55
+
56
+ with col3:
57
+ st.metric("Status", "Active" if not game_controller.game_done else "Ended")