A modern, interactive Python-based traffic simulation that visualizes operating system scheduling algorithms through a stunning intersection with vehicles, traffic lights, and real-time analytics.
- Dark Mode Aesthetic: Modern dark theme with blue accents
- 3D Vehicle Graphics: Detailed vehicles with realistic styling
- Glowing Traffic Lights: Animated lights with glow effects
- Real-time Graphs: Live statistics and performance charts
- Smooth Animations: 60 FPS fluid animations throughout
- Comprehensive Keyboard Shortcuts: Full control via keyboard
- Audio System: Sound effects and ambient traffic noise
- Tooltip System: Contextual help on hover
- Modern Menu System: Animated menus with hover effects
- Real-time Visualizations: Live data charts and progress bars
- Four Scheduling Algorithms: FCFS, Round Robin, Priority, and Dynamic
- Problem Scenarios: Deadlock, starvation, priority inversion, thrashing
- Performance Metrics: Throughput, queue lengths, congestion levels
- Visual Learning: Learn OS concepts through interactive simulation
# Clone the repository
git clone <repository-url>
cd Traffic_simulation
# Install dependencies
pip install -r requirements.txt
# Run the modern simulation
python main.py| Key | Action |
|---|---|
| SPACE | Pause/Resume simulation |
| 1-4 | Switch algorithms (FCFS, Round Robin, Priority, Dynamic) |
| F / F11 | Toggle fullscreen |
| F12 | Minimize window |
| M | Show main menu |
| R | Reset simulation |
| + / = | Increase simulation speed |
| - | Decrease simulation speed |
| H | Show help |
| S | Toggle sound effects |
| A | Toggle ambient audio |
| ESC | Quit application |
- Theme Engine: Centralized styling and theming
- Gradient Backgrounds: Dynamic sky and atmospheric effects
- Rounded Corners: Modern UI design throughout
- Shadow Effects: Visual depth and hierarchy
- Responsive Design: Adapts to different screen sizes
- Queue Length Graphs: Live line charts showing traffic flow
- Throughput Visualization: Real-time performance metrics
- Circular Progress Bars: Modern progress indicators
- Statistics Dashboard: Comprehensive data visualization
- Sound Effects: Traffic lights, vehicle passing, button clicks
- Ambient Audio: Background traffic noise
- Volume Control: Adjustable audio levels
- Toggle Options: Easy sound management
- 3D Vehicle Sprites: Detailed cars, buses, bikes, and ambulances
- Glowing Effects: Pulsing traffic lights and status indicators
- Particle Effects: Floating atmospheric particles
- Smooth Animations: Fluid transitions and movements
- Concept: Processes served in arrival order
- Visual: Simple queue-based traffic flow
- Learning: Basic scheduling principles
- Concept: Equal time slices for each direction
- Visual: Alternating traffic light patterns
- Learning: Fair scheduling and time management
- Concept: High-priority processes served first
- Visual: Emergency vehicles get immediate access
- Learning: Priority-based resource allocation
- Concept: Adaptive scheduling based on conditions
- Visual: Traffic lights adapt to queue lengths
- Learning: Intelligent resource management
- Deadlock: All vehicles waiting for each other
- Starvation: Some vehicles never get served
- Priority Inversion: Low priority blocks high priority
- Thrashing: Too many context switches
- Real-time Metrics: See algorithm performance live
- Interactive Controls: Experiment with different settings
- Visual Feedback: Immediate response to changes
- Comparative Analysis: Switch between algorithms easily
- Modular Architecture: Separated concerns and reusable components
- Theme System: Centralized styling and theming
- Audio Manager: Dedicated audio system
- Graphics Utilities: Reusable drawing functions
- Animation Framework: Smooth animation system
- Efficient Rendering: Optimized drawing routines
- Memory Management: Proper sprite caching
- Smooth Animations: 60 FPS performance
- Audio Optimization: Efficient sound mixing
Traffic_simulation/
โโโ main.py # Main simulation entry point
โโโ ui/ # Modern UI system
โ โโโ theme.py # Theme and styling system
โ โโโ background.py # Enhanced background graphics
โ โโโ dashboard.py # Modern dashboard with analytics
โ โโโ menu.py # Animated menu system
โ โโโ tooltip.py # Tooltip system
โ โโโ visualizations.py # Real-time charts and graphs
โ โโโ audio.py # Audio system
โโโ controllers/ # Simulation controllers
โโโ entities/ # Game entities (vehicles, lanes)
โโโ assets/ # Graphics and audio assets
Edit ui/theme.py to customize:
- Color palette and accent colors
- Font sizes and typography
- Spacing and border radius
- Animation parameters
Modify ui/audio.py to:
- Add custom sound effects
- Adjust volume levels
- Create new audio events
- Customize ambient sounds
- Particle Effects: Vehicle exhaust and environmental effects
- Weather System: Dynamic weather conditions
- Day/Night Cycle: Time-based lighting changes
- 3D Graphics: Optional 3D rendering mode
- VR Support: Virtual reality compatibility
- GPU Acceleration: Hardware-accelerated rendering
- Level of Detail: Distance-based optimization
- Instancing: Efficient batch rendering
- Culling: Off-screen object optimization
- Python 3.7+: Required for modern features
- Pygame 2.0+: For enhanced graphics capabilities
- Audio Support: Optional audio features
- Modern Hardware: Recommended for smooth animations
- Efficient Rendering: Optimized drawing routines
- Memory Management: Proper resource cleanup
- Smooth Animations: Consistent 60 FPS
- Audio Optimization: Efficient sound processing
We welcome contributions! Please see our contributing guidelines for:
- Code style and standards
- Feature request process
- Bug report format
- Pull request guidelines
This project is licensed under the MIT License - see the LICENSE file for details.
- Pygame Community: For the excellent game development framework
- Educational Community: For feedback and suggestions
- Open Source Contributors: For inspiration and best practices
Experience the future of educational simulations with our modern, interactive Traffic Simulation! ๐๐จ