Congratulations to Kamran for the best response to this challenge!
We were impressed by your simulation and also the inclusion of variable weather elements.
This Challenge is now closed but entries can still be posted and votes can still be cast.
Original Post:
We’re excited to have a new series of Challenges for the Stack Overflow community. We’ll be posting one challenge every day this week. This challenge comes from Stack Overflow user @andam. If you’d like to submit a challenge for consideration, please head over to the Sandbox.
This challenge is to create a Traffic Light Simulator.
The Challenge
Traffic systems are everywhere, and they can get chaotic! The challenge is to simulate a traffic intersection where cars spawn randomly at each side of a traffic light.
Requirements:
Cars spawn randomly at each traffic light side.
Traffic rules should be respected (e.g., don’t block turning lanes, obey light cycles).
Bonus:
Add weather conditions (rain, fog, etc.) that affect driving behavior.
Cars can have unique traits like drifting while turning, honking when the light turns green, etc.
Include pedestrians crossing.
Implement car crashes or collisions for chaotic fun.
Skills Needed: HTML, CSS, JavaScript (with optional canvas animations or game libraries).
How does the actual contest work?
You have two weeks from the date this challenge is posted to submit your entry. During this period, other entries are only visible once you have submitted your own. After that, anyone can view and vote on others’ entries. After you submit, or during the voting period, please vote on whichever entries seem the most interesting or noteworthy. Our goal is to encourage creative approaches, and this challenge does not have specific performance criteria.
User entries with the highest vote score will be recognized. Please note that any votes received as part of this challenge do not count towards site reputation.
To keep the voting fair, we’ve hidden the vote counts until the end of the challenge. The scores will be unhidden on October 6, and we’ll announce the winners soon after that.
September 15: Challenge goes live
September 29: All entries visible to everyone. Vote scores are hidden to reduce voting bias.
October 6: Challenge ends. Vote counts and winners are announced.
How to Submit:
Enter your completed entry in the text box below.
Your submission should include:
An explanation of your approach
The code you have written
Instructions for how others can run your code to observe how it works. Hosting your code on an online code editor often works well for this.
Anything you learned or any interesting challenges you faced while coding!
Your entry is not permitted to be written by AI.
I have taken help of AI to understand the question as first i thought I have to make a clean traffict light simulator where no collision occur.
Here Is my work so far:
https://jsfiddle.net/rh41cks7/