https://github.com/willkirkmanm/traffic
Four Way Traffic Simulator with Lights & Vehicles Following Traffic Rules
https://github.com/willkirkmanm/traffic
parsonlabs simulation traffix
Last synced: about 1 year ago
JSON representation
Four Way Traffic Simulator with Lights & Vehicles Following Traffic Rules
- Host: GitHub
- URL: https://github.com/willkirkmanm/traffic
- Owner: WillKirkmanM
- Created: 2025-05-09T22:17:16.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2025-05-09T22:26:24.000Z (about 1 year ago)
- Last Synced: 2025-05-19T01:13:21.071Z (about 1 year ago)
- Topics: parsonlabs, simulation, traffix
- Language: Rust
- Homepage:
- Size: 21.5 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Traffic
Four Way Traffic Simulator with Lights & Vehicles Following Traffic Rules
## Features
- **Intersection with Traffic Lights**: Four-way intersection with coordinated traffic lights
- **Vehicle AI**: Vehicles that react to traffic lights and avoid collisions
- **Realistic Movement**: Vehicles accelerate, decelerate, and stop based on traffic conditions
- **Visual Feedback**: Color-coded traffic lights and directional vehicles
## Traffic Light Algorithm
The simulation implements a simple time-based traffic light algorithm:
1. **Coordination**: East-west and north-south lights are coordinated to avoid conflicts
2. **Cycle**: Each light cycles through Red (5s) → Green (5s) → Yellow (2s) → Red
3. **Priority**: When east-west lights are green, north-south lights are red and vice versa
## Vehicle Behavior
Vehicles in the simulation exhibit several intelligent behaviors:
- Stop at red and yellow traffic lights
- Maintain safe distances from other vehicles
- Accelerate when the path is clear
- Travel at different speeds (randomized for each vehicle)
- Automatically despawn when out of view
## Running the Simulation
### Prerequisites
- Rust and Cargo (1.39 or newer)
### Installation
1. Clone this repository
```bash
git clone https://github.com/WillKirkmanM/traffic.git
```
2. Build and run:
```bash
cargo build --release
cargo run --release
```