Spaces:
Sleeping
Sleeping
fix feedback
Browse files
app.py
CHANGED
|
@@ -154,8 +154,13 @@ CUSTOM_CSS = """
|
|
| 154 |
}
|
| 155 |
|
| 156 |
.status-text {
|
| 157 |
-
color: #
|
| 158 |
-
font-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 159 |
}
|
| 160 |
|
| 161 |
.game-over-text {
|
|
@@ -836,11 +841,14 @@ def new_game(seed_input: str):
|
|
| 836 |
valid_actions = game.get_valid_actions(0)
|
| 837 |
action_choices = [f"{code}: {desc}" for code, desc in valid_actions]
|
| 838 |
|
|
|
|
|
|
|
|
|
|
| 839 |
return (
|
| 840 |
game,
|
| 841 |
format_game_display(game),
|
| 842 |
format_history(game),
|
| 843 |
-
|
| 844 |
gr.update(choices=action_choices, value=action_choices[0] if action_choices else None, interactive=True),
|
| 845 |
gr.update(interactive=True),
|
| 846 |
)
|
|
@@ -853,7 +861,7 @@ def play_action(game: TinyHanabiGame, action_choice: str):
|
|
| 853 |
None,
|
| 854 |
format_game_display(None),
|
| 855 |
"",
|
| 856 |
-
"Please start a new game first.
|
| 857 |
gr.update(choices=[], interactive=False),
|
| 858 |
gr.update(interactive=False),
|
| 859 |
)
|
|
@@ -863,7 +871,7 @@ def play_action(game: TinyHanabiGame, action_choice: str):
|
|
| 863 |
game,
|
| 864 |
format_game_display(game),
|
| 865 |
format_history(game),
|
| 866 |
-
f"Game over! {game.game_over_reason}. Final score: {game.score}/{CONFIG.max_score}
|
| 867 |
gr.update(choices=[], interactive=False),
|
| 868 |
gr.update(interactive=False),
|
| 869 |
)
|
|
@@ -874,14 +882,15 @@ def play_action(game: TinyHanabiGame, action_choice: str):
|
|
| 874 |
# Execute human action
|
| 875 |
feedback = game.execute_action(0, action)
|
| 876 |
game.advance_turn(feedback)
|
| 877 |
-
status = f"You: {feedback}"
|
| 878 |
|
| 879 |
if game.game_over:
|
|
|
|
|
|
|
| 880 |
return (
|
| 881 |
game,
|
| 882 |
format_game_display(game),
|
| 883 |
format_history(game),
|
| 884 |
-
|
| 885 |
gr.update(choices=[], interactive=False),
|
| 886 |
gr.update(interactive=False),
|
| 887 |
)
|
|
@@ -890,14 +899,17 @@ def play_action(game: TinyHanabiGame, action_choice: str):
|
|
| 890 |
ai_action = get_ai_action(game)
|
| 891 |
ai_feedback = game.execute_action(1, ai_action)
|
| 892 |
game.advance_turn(ai_feedback)
|
| 893 |
-
|
|
|
|
|
|
|
| 894 |
|
| 895 |
if game.game_over:
|
|
|
|
| 896 |
return (
|
| 897 |
game,
|
| 898 |
format_game_display(game),
|
| 899 |
format_history(game),
|
| 900 |
-
|
| 901 |
gr.update(choices=[], interactive=False),
|
| 902 |
gr.update(interactive=False),
|
| 903 |
)
|
|
@@ -906,11 +918,13 @@ def play_action(game: TinyHanabiGame, action_choice: str):
|
|
| 906 |
valid_actions = game.get_valid_actions(0)
|
| 907 |
action_choices = [f"{code}: {desc}" for code, desc in valid_actions]
|
| 908 |
|
|
|
|
|
|
|
| 909 |
return (
|
| 910 |
game,
|
| 911 |
format_game_display(game),
|
| 912 |
format_history(game),
|
| 913 |
-
|
| 914 |
gr.update(choices=action_choices, value=action_choices[0] if action_choices else None, interactive=True),
|
| 915 |
gr.update(interactive=True),
|
| 916 |
)
|
|
@@ -962,7 +976,7 @@ with gr.Blocks(title="Tiny Hanabi", css=CUSTOM_CSS, theme=gr.themes.Base()) as d
|
|
| 962 |
elem_classes=["action-btn"]
|
| 963 |
)
|
| 964 |
|
| 965 |
-
status_display = gr.
|
| 966 |
|
| 967 |
# Events
|
| 968 |
new_game_btn.click(
|
|
|
|
| 154 |
}
|
| 155 |
|
| 156 |
.status-text {
|
| 157 |
+
color: #e0e0e0 !important;
|
| 158 |
+
font-size: 1.1em !important;
|
| 159 |
+
line-height: 1.6 !important;
|
| 160 |
+
padding: 10px !important;
|
| 161 |
+
background: rgba(0, 0, 0, 0.3) !important;
|
| 162 |
+
border-radius: 8px !important;
|
| 163 |
+
margin-top: 10px !important;
|
| 164 |
}
|
| 165 |
|
| 166 |
.game-over-text {
|
|
|
|
| 841 |
valid_actions = game.get_valid_actions(0)
|
| 842 |
action_choices = [f"{code}: {desc}" for code, desc in valid_actions]
|
| 843 |
|
| 844 |
+
status = f'<p style="color: #2a9d8f;">Game started! Seed: {game.seed}</p>'
|
| 845 |
+
status += '<p style="color: #ffd700; font-weight: bold;">Your turn!</p>'
|
| 846 |
+
|
| 847 |
return (
|
| 848 |
game,
|
| 849 |
format_game_display(game),
|
| 850 |
format_history(game),
|
| 851 |
+
status,
|
| 852 |
gr.update(choices=action_choices, value=action_choices[0] if action_choices else None, interactive=True),
|
| 853 |
gr.update(interactive=True),
|
| 854 |
)
|
|
|
|
| 861 |
None,
|
| 862 |
format_game_display(None),
|
| 863 |
"",
|
| 864 |
+
'<p style="color: #e63946;">Please start a new game first.</p>',
|
| 865 |
gr.update(choices=[], interactive=False),
|
| 866 |
gr.update(interactive=False),
|
| 867 |
)
|
|
|
|
| 871 |
game,
|
| 872 |
format_game_display(game),
|
| 873 |
format_history(game),
|
| 874 |
+
f'<p style="color: #ffd700; font-weight: bold;">Game over! {game.game_over_reason}. Final score: {game.score}/{CONFIG.max_score}</p>',
|
| 875 |
gr.update(choices=[], interactive=False),
|
| 876 |
gr.update(interactive=False),
|
| 877 |
)
|
|
|
|
| 882 |
# Execute human action
|
| 883 |
feedback = game.execute_action(0, action)
|
| 884 |
game.advance_turn(feedback)
|
|
|
|
| 885 |
|
| 886 |
if game.game_over:
|
| 887 |
+
status = f'<p><strong style="color: #ffd700;">You:</strong> {feedback}</p>'
|
| 888 |
+
status += f'<p style="color: #ffd700; font-weight: bold; margin-top: 10px;">Game over! {game.game_over_reason}. Final score: {game.score}/{CONFIG.max_score}</p>'
|
| 889 |
return (
|
| 890 |
game,
|
| 891 |
format_game_display(game),
|
| 892 |
format_history(game),
|
| 893 |
+
status,
|
| 894 |
gr.update(choices=[], interactive=False),
|
| 895 |
gr.update(interactive=False),
|
| 896 |
)
|
|
|
|
| 899 |
ai_action = get_ai_action(game)
|
| 900 |
ai_feedback = game.execute_action(1, ai_action)
|
| 901 |
game.advance_turn(ai_feedback)
|
| 902 |
+
|
| 903 |
+
status = f'<p><strong style="color: #ffd700;">You:</strong> {feedback}</p>'
|
| 904 |
+
status += f'<p><strong style="color: #4dabf7;">AI ({ai_action}):</strong> {ai_feedback}</p>'
|
| 905 |
|
| 906 |
if game.game_over:
|
| 907 |
+
status += f'<p style="color: #ffd700; font-weight: bold; margin-top: 10px;">Game over! {game.game_over_reason}. Final score: {game.score}/{CONFIG.max_score}</p>'
|
| 908 |
return (
|
| 909 |
game,
|
| 910 |
format_game_display(game),
|
| 911 |
format_history(game),
|
| 912 |
+
status,
|
| 913 |
gr.update(choices=[], interactive=False),
|
| 914 |
gr.update(interactive=False),
|
| 915 |
)
|
|
|
|
| 918 |
valid_actions = game.get_valid_actions(0)
|
| 919 |
action_choices = [f"{code}: {desc}" for code, desc in valid_actions]
|
| 920 |
|
| 921 |
+
status += '<p style="color: #2a9d8f; margin-top: 10px;">Your turn!</p>'
|
| 922 |
+
|
| 923 |
return (
|
| 924 |
game,
|
| 925 |
format_game_display(game),
|
| 926 |
format_history(game),
|
| 927 |
+
status,
|
| 928 |
gr.update(choices=action_choices, value=action_choices[0] if action_choices else None, interactive=True),
|
| 929 |
gr.update(interactive=True),
|
| 930 |
)
|
|
|
|
| 976 |
elem_classes=["action-btn"]
|
| 977 |
)
|
| 978 |
|
| 979 |
+
status_display = gr.HTML("", elem_classes=["status-text"])
|
| 980 |
|
| 981 |
# Events
|
| 982 |
new_game_btn.click(
|