Skip to content

RoshRaj01/Hospital_Emergency_Simulation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 

Repository files navigation

Hospital Manager – Emergency Room Simulation 🏥

A real-time Emergency Room simulation built using Python and Pygame. This project models a multi-server priority queueing system using discrete-event simulation principles.

The system simulates stochastic patient arrivals, severity-based prioritization, doctor assignment, and treatment completion in a dynamic graphical environment.


Game Screenshots

Emergency Room View

image

Patient Under Treatment

image

Waiting Area Queue

image

Features

  • Real-time discrete-event simulation
  • Multi-doctor (multi-server) system
  • Severity-based priority queue (Critical > Moderate > Minor)
  • Heap-based scheduling using heapq
  • Adjustable number of doctors
  • Adjustable patient arrival probability
  • Custom simulation duration (in minutes)
  • Start / Pause / Resume / Restart controls
  • Scrollable hospital layout
  • Live statistics panel (time, queue size, treated count)

Simulation Model

Patient Severity Structure

Severity Priority Service Time (seconds)
Critical 1 20 – 30
Moderate 2 10 – 20
Minor 3 5 – 10

Lower numerical priority means higher urgency.

The system follows a non-preemptive priority queue discipline.


How It Works

Each simulation step:

  1. Increments simulation time
  2. Generates patient arrivals probabilistically
  3. Updates service time for busy doctors
  4. Releases doctors when treatment completes
  5. Assigns highest-priority waiting patient
  6. Updates waiting time of queued patients

The simulation ends when the defined duration is reached.


Performance Metrics

The simulation tracks:

  • Total patients treated
  • Queue length
  • Simulation time
  • Throughput
  • Doctor utilization
  • Average waiting time

These metrics allow analysis of congestion and system stability.


Project Structure

Hospital-Simulation/
│
├── config.py
├── entities.py
├── simulation.py
├── ui.py
├── main.py
├── Assets/

Installation & Run

Requirements

  • Python 3.x
  • Pygame

Install Pygame

pip install pygame

Run the Simulation

python main.py

Mathematical Model

Arrival Rate:

λ = p

Service Rate:

μ = 1 / Avg(Service Time)

Utilization:

ρ = λ / (cμ)

Where:

  • c = number of doctors
  • Stability condition: ρ < 1

If ρ ≥ 1, the queue grows without bound.


Concepts Demonstrated

  • Discrete Event Simulation
  • Priority Queues
  • Multi-Server Queueing Systems
  • Stochastic Modeling
  • Event-Driven Programming
  • Real-Time GUI Rendering

This project serves as a dynamic experimental tool for analyzing emergency department congestion, resource allocation, and system stability under uncertainty.

About

A Pygame-based simulation that models patient arrivals, priority queues, and doctor assignment in an emergency room using real-time scheduling logic.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages