-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_simulation.py
More file actions
54 lines (44 loc) · 1.4 KB
/
run_simulation.py
File metadata and controls
54 lines (44 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env python3
"""
Launcher script for the Traffic Simulation.
This script provides an easy way to run the simulation with error handling.
"""
import sys
import os
def main():
"""Launch the traffic simulation."""
print("🚦 Traffic Simulation - OS Scheduling Demo")
print("=" * 50)
try:
# Check if pygame is available
try:
import pygame
print(f"✓ Pygame {pygame.version.ver} detected")
except ImportError:
print("❌ Pygame not found. Please install it with:")
print(" pip install pygame")
return 1
# Import and run simulation
from main import TrafficSimulation
print("✓ Starting simulation...")
print("\nControls:")
print(" 1-4: Switch algorithms")
print(" SPACE: Pause/Resume")
print(" ESC: Quit")
print("\nStarting in 3 seconds...")
import time
time.sleep(3)
# Create and run simulation
simulation = TrafficSimulation()
simulation.run()
except KeyboardInterrupt:
print("\n\n👋 Simulation stopped by user")
return 0
except Exception as e:
print(f"\n❌ Error running simulation: {e}")
import traceback
traceback.print_exc()
return 1
return 0
if __name__ == "__main__":
sys.exit(main())