Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -593,8 +593,56 @@ def save_logs_and_upload(state: dict):
|
|
| 593 |
# 4. Streamlit UI (Applying v4.22 + v4.23 fixes)
|
| 594 |
# -----------------------------------------------------------------------------
|
| 595 |
st.title("🍺 The Beer Game: A Human-AI Collaboration Challenge")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 596 |
if st.session_state.get('initialization_error'):
|
| 597 |
st.error(st.session_state.initialization_error)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 598 |
else:
|
| 599 |
# --- Game Setup & Instructions ---
|
| 600 |
if 'game_state' not in st.session_state or not st.session_state.game_state.get('game_running', False):
|
|
@@ -656,13 +704,7 @@ else:
|
|
| 656 |
state = st.session_state.game_state
|
| 657 |
week, human_role, echelons, info_sharing = state['week'], state['human_role'], state['echelons'], state['info_sharing']
|
| 658 |
echelon_order = ["Retailer", "Wholesaler", "Distributor", "Factory"] # Define here for UI
|
| 659 |
-
|
| 660 |
-
# [修改点 1.1]: 移除 st.columns,恢复主内容到左侧,侧边栏不变
|
| 661 |
-
# col_main, col_sidebar_image = st.columns([4, 1]) 移除
|
| 662 |
-
|
| 663 |
-
# with col_main: 移除
|
| 664 |
st.header(f"Week {week} / {WEEKS}")
|
| 665 |
-
# [修改点 2.3]: 移除 subheader 中 AI Mode 和 Information 的提示
|
| 666 |
st.subheader(f"Your Role: **{human_role}** ({state['participant_id']})")
|
| 667 |
st.markdown("---")
|
| 668 |
st.subheader("Supply Chain Status (Start of Week State)")
|
|
@@ -810,11 +852,9 @@ else:
|
|
| 810 |
except Exception as e:
|
| 811 |
st.error(f"Error displaying weekly log: {e}")
|
| 812 |
|
| 813 |
-
# [修改点 1.2]: 恢复 Game Info 和图片到 st.sidebar
|
| 814 |
-
# 移除 with col_sidebar_image:
|
| 815 |
st.sidebar.header("Game Info")
|
| 816 |
st.sidebar.markdown(f"**Game ID**: `{state['participant_id']}`\n\n**Current Week**: {week}")
|
| 817 |
-
|
| 818 |
try: st.sidebar.image(IMAGE_PATH, caption="Supply Chain Reference", use_column_width=True)
|
| 819 |
except FileNotFoundError: st.sidebar.warning("Image file not found.")
|
| 820 |
|
|
@@ -832,7 +872,6 @@ else:
|
|
| 832 |
logs_df = pd.json_normalize(state['logs'])
|
| 833 |
fig = plot_results(
|
| 834 |
logs_df,
|
| 835 |
-
# [修改点 2.4]: 移除报告标题中的实验条件提示
|
| 836 |
f"Beer Game (Human: {state['human_role']})",
|
| 837 |
state['human_role']
|
| 838 |
)
|
|
|
|
| 593 |
# 4. Streamlit UI (Applying v4.22 + v4.23 fixes)
|
| 594 |
# -----------------------------------------------------------------------------
|
| 595 |
st.title("🍺 The Beer Game: A Human-AI Collaboration Challenge")
|
| 596 |
+
|
| 597 |
+
# --- NEW: Check for Consent ---
|
| 598 |
+
if 'consent_given' not in st.session_state:
|
| 599 |
+
st.session_state['consent_given'] = False
|
| 600 |
+
|
| 601 |
+
# --- Initialization Check ---
|
| 602 |
if st.session_state.get('initialization_error'):
|
| 603 |
st.error(st.session_state.initialization_error)
|
| 604 |
+
# --- Consent Form Display Logic ---
|
| 605 |
+
elif not st.session_state['consent_given']:
|
| 606 |
+
st.header("📝 Participant Consent Form (参与者知情同意书)")
|
| 607 |
+
st.markdown("""
|
| 608 |
+
**Project Title:** Behavioural Contagion or Rational Alignment? Human Performance in LLM Supply Chains
|
| 609 |
+
|
| 610 |
+
**Lead Researcher:** Xinyu Li
|
| 611 |
+
**Supervisor:** Professor Li Ding & Dr Yanlu Zhao
|
| 612 |
+
**Contact Email:** xinyu.li3@durham.ac.uk
|
| 613 |
+
|
| 614 |
+
Please read the following statements carefully. If you have any questions, please ask the researcher or contact them at the email address provided above.
|
| 615 |
+
|
| 616 |
+
By agreeing to participate, you are confirming that you understand all of the following:
|
| 617 |
+
|
| 618 |
+
- You have listened to the in-class explanation of this study and have had the opportunity to ask questions.
|
| 619 |
+
- Your participation is completely **voluntary**, and you are free to withdraw at any time up to the point of final data submission, without giving a reason.
|
| 620 |
+
- Your decision to participate (or not participate), and your performance during the simulation, will have **no impact on your course grade** or academic standing for BUSI55215 or any other course.
|
| 621 |
+
- Your participation is completely **anonymous**, and no personally identifiable information (like your name or student ID) will be collected.
|
| 622 |
+
- Because all data is anonymous, it will be impossible to withdraw your data after you have completed the session and submitted the final survey.
|
| 623 |
+
- You understand the primary benefit is educational and the risks are minimal.
|
| 624 |
+
- You understand that your anonymised research data may be shared with, and used by, others for future research (no one will be able to identify you when these data are shared).
|
| 625 |
+
- You confirm that you are **18 years of age or older**.
|
| 626 |
+
""")
|
| 627 |
+
|
| 628 |
+
st.markdown("---")
|
| 629 |
+
|
| 630 |
+
consent_choice = st.radio(
|
| 631 |
+
"**Do you agree to take part in this study?**",
|
| 632 |
+
('Yes, I agree to participate in this study.', 'No, I do not agree to participate in this study.'),
|
| 633 |
+
index=None
|
| 634 |
+
)
|
| 635 |
+
|
| 636 |
+
if st.button("Continue / 提交"):
|
| 637 |
+
if consent_choice == 'Yes, I agree to participate in this study.':
|
| 638 |
+
st.session_state['consent_given'] = True
|
| 639 |
+
st.rerun()
|
| 640 |
+
elif consent_choice == 'No, I do not agree to participate in this study.':
|
| 641 |
+
st.error("Thank you for your time. Since you declined participation, the experiment will not proceed.")
|
| 642 |
+
else:
|
| 643 |
+
st.warning("Please select an option to continue.")
|
| 644 |
+
|
| 645 |
+
# --- Game Setup / Main Interface Logic ---
|
| 646 |
else:
|
| 647 |
# --- Game Setup & Instructions ---
|
| 648 |
if 'game_state' not in st.session_state or not st.session_state.game_state.get('game_running', False):
|
|
|
|
| 704 |
state = st.session_state.game_state
|
| 705 |
week, human_role, echelons, info_sharing = state['week'], state['human_role'], state['echelons'], state['info_sharing']
|
| 706 |
echelon_order = ["Retailer", "Wholesaler", "Distributor", "Factory"] # Define here for UI
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 707 |
st.header(f"Week {week} / {WEEKS}")
|
|
|
|
| 708 |
st.subheader(f"Your Role: **{human_role}** ({state['participant_id']})")
|
| 709 |
st.markdown("---")
|
| 710 |
st.subheader("Supply Chain Status (Start of Week State)")
|
|
|
|
| 852 |
except Exception as e:
|
| 853 |
st.error(f"Error displaying weekly log: {e}")
|
| 854 |
|
|
|
|
|
|
|
| 855 |
st.sidebar.header("Game Info")
|
| 856 |
st.sidebar.markdown(f"**Game ID**: `{state['participant_id']}`\n\n**Current Week**: {week}")
|
| 857 |
+
|
| 858 |
try: st.sidebar.image(IMAGE_PATH, caption="Supply Chain Reference", use_column_width=True)
|
| 859 |
except FileNotFoundError: st.sidebar.warning("Image file not found.")
|
| 860 |
|
|
|
|
| 872 |
logs_df = pd.json_normalize(state['logs'])
|
| 873 |
fig = plot_results(
|
| 874 |
logs_df,
|
|
|
|
| 875 |
f"Beer Game (Human: {state['human_role']})",
|
| 876 |
state['human_role']
|
| 877 |
)
|