π‘ Inspiration
We were inspired by the intense, high-stakes decisions that hospital staff make every single night. A charge nurse on the "Night Shift" is constantly playing a game of high-stakes triage: who gets the last ventilator? Who gets the only available nurse? This human-driven optimization is incredibly difficult. We wanted to see if a modern AI, trained on millions of scenarios, could discover optimal, life-saving strategies that even the most experienced human might miss.
π©Ί What it does
Night Shift is a "Digital Twin" of an ICU in crisis. It has two modes:
- "Retro" Mode: A top-down
Pygamesimulator where you, the human, try to manage the ICU. You must manually allocate nurses, beds, and ventilators to save patients as their severity increases. - "Modern" AI Mode: We run the exact same simulation, but this time it's controlled by an AI we trained using reinforcement learning. It acts as a Decision Support System, executing the optimal strategy it learned from millions of simulations to save the maximum number of lives.
It's a "flight simulator for nurses" that doubles as a powerful planning tool for hospital administrators.
π οΈ How we built it
The project is built entirely in Python with two main components:
- The Simulation Engine: A core
SimICUclass that models all the logic: patient arrivals (Poisson process), severity degradation, and resource constraints. - The AI Environment: We wrapped our engine in a Gymnasium-compatible environment. This included a normalized
observation_space(patient severity, wait times, free resources) and aMultiDiscreteaction space(patient_id, action_type). - The AI Agent: We used Stable-Baselines3 to train a Proximal Policy Optimization (PPO) agent on our environment.
- The "Retro" UI: We used Pygame to build the human-playable "Retro" game, which calls the same underlying simulation engine.
π₯ Challenges we ran into
The AI did not work. At all. Our first agent had a 1.1% success rateβit was acting randomly and everyone was lost. The biggest challenge was debugging the environment (the teacher), not the agent (the student).
- State Normalization: The AI saw numbers like
tick=1000andfree_beds=5and thought the tick count was 200x more important. We had to normalize all state inputs to a[0, 1]range so it could understand the relative importance of each factor. - Reward Shaping: A single
+100reward for a save wasn't enough; the AI didn't know which of its 500 actions led to the win. We had to add frequent, small penalties for every tick a patient waited, teaching it a sense of urgency. - Invalid Actions: The agent wasted thousands of steps trying to act on non-existent patients. We had to add large, immediate penalties for any invalid action, forcing it to learn the rules before it could learn the strategy.
π Accomplishments that we're proud of
We're incredibly proud of turning that 1.1% success rate into a high-performing agent. Debugging an RL environment is notoriously difficult, and we successfully navigated state normalization and complex reward shaping. Most importantly, we're proud of building a project that is more than a "game"βit's a high-fidelity "Digital Twin" that can be directly applied to a real-world healthcare problem.
π What we learned
We learned that "DigitalTwins" are incredibly powerful. Our "Retro" sim isn't just a game; it's a baseline for human performance. Our "Modern" AI isn't just an opponent; it's a Decision Support System.
By building this, we learned how to model a complex, real-world system and, more importantly, how to teach an AI to master it. The challenges taught us that the quality of the environment and the clarity of the reward are far more important than the agent's algorithm.
π What's next for Night Shift
This is just the beginning. The next steps are focused on real-world deployment:
- Explainable AI (XAI): Build a dashboard that shows why the AI is making its recommendations in plain English. A doctor will never trust a black box, so we need to add transparency.
- Higher Fidelity: Deepen the model by adding patient archetypes (e.g., cardiac vs. respiratory) and specialized resources, making the simulation even more realistic.
- EMR Integration: Create a mock-up showing how Night Shift could plug into a real hospital's EMR system and provide live, actionable recommendations to staff.
Log in or sign up for Devpost to join the conversation.