
Show HN: A Simple Highway Simulator - Silvanm
http://muehlemann.com/highwaysim
======
cyberferret
Interesting project! I had fun playing with it. I wanted to test the theory
(which I saw in an article posted here on HN a few weeks ago) that a single
car slowing right down on a busy highway (e.g. to avoid hitting an animal on
the road or similar) can actually cause a traffic jam that goes back miles and
can last for hours.

I couldn't prove that hypothesis at this scale. I am assuming that the AI
drivers have just too good a reaction time and they can co-ordinate their
speeds to each other to keep things moving along fairly nicely. A thumbs up
for robot driverless cars, I guess ;-)

EDIT: Actually, playing some more - it does prove it to some extent. If you
increase reaction time to ~800ms and let the traffic blitz along at a steady
clip, then slow down two cars side by side to almost a stop, then after the
initial cascade of accidents, it take ages for the traffic to get back to the
same steady pace. Interesting.

~~~
mabcat
The 200ms default reaction time in the simulation is wildly optimistic. I
remember 1500ms from rider training and
[http://www.visualexpert.com/Resources/reactiontime.html](http://www.visualexpert.com/Resources/reactiontime.html)
seems to bear that out.

~~~
novaleaf
also braking: it looks like the cars can only brake as fast as they
accelerate. seems like this should be a different slider.

------
puddintane
What is the number for the Simple Highway Police Department, I just witnessed
3 hit and runs back-to-back and would like to report them!

Neat idea and while it's still at a very basic stage it'll be cool to see this
evolve into something that could eventually be used by traffic controllers!

------
scotty79
What I'm missing is right lane preference, that would control how much people
obey the rule that you shouldn't be on the leftmost lane unless you are faster
then the cars in the right lane in front of you and if you aren't much faster
then the car that's next to you on the right lane you should slow down and
place yourself after it or speed up and place yourself in front of it.

It's horribly painful to watch two slow cars occupying both lanes next to each
other.

~~~
tragomaskhalos
Or indeed left-lane preference, for British and Japanese users. But yes a more
sophisticated simulation would use > 2 lanes, and have various controls for
lane discipline, especially since poor lane discipline is a major contributor
to congestion. This is a suggestion not a criticism btw, I had fun with this.

------
erentz
Those cars are using indicators, this is clearly not based in California.

~~~
gerdesj
The dev is Swiss and holidaying in Spain.

~~~
eb0la
Then he's not driving in Spain. Same as California here. Probably like the
rest of the world except Switzerland :-(

~~~
julianwachholz
Don't worry, we have BMW drivers here, too.

------
lucb1e
Some bugs (cars not always breaking when another is standing still ahead; cars
crashing at the beginning if you hit launch too quickly), but overall a fun
toy to play with. I would like to know what realistic values are though: I
know that 200ms reaction time is a good case, but what are actual average
cases? It should be set to that by default. Or acceleration speed, is 5km/h
realistic? 10? When set to 5, I cannot simulate a normal highway (they'll
never go over 100) because the track is fairly short.

~~~
zodPod
I think the braking is a feature not a bug. See the "reaction time" I'd assume
that means that some just aren't reacting in time to not hit the car ahead.

~~~
lucb1e
That might be, I don't know when they would have started to break but they
were extremely late if ever. But perhaps it was well within the reaction time
I set (350ms), for me it's easy to think they just kept driving because I saw
them coming from afar.

------
jtolmar
Here's something fun and counter-intuitive:

From default settings, set speed variance to 50%, launch frequency to 120
cars/minute, and reaction time to 500ms. Unsurprisingly, this is chaos.

Then, keeping those settings, clear the cars and set the target speed to
150km/h. The traffic mostly clears up! Since the cars are going faster, they
leave the road sooner, meaning fewer are on the road at a time, fixing most
problems.

(Of course, in real life, this also makes the accidents that do occur worse.)

~~~
buzzybee
Something this sim doesn't model that plays a large role in real accidents is
the speed differentials during merges. If an offramp moves too slowly and gets
fully congested, it starts spreading onto the highway, compounding the
problem.

Playing Cities: Skylines I've noticed a similar problem when I try to use
roundabouts. They're idealized as a way to keep traffic flowing in busy
intersections by imposing no stops, but if they surpass a critical mass of
congestion, the whole thing stalls, creating a problem worse than stop lights.

(The Cities traffic model is pretty close to how a robocar might behave, as
they are polite drivers able to execute apparently dangerous merges with 0%
chance of collision, but also have the problem of not detouring when the ideal
route becomes congested. As a result, you have to design your city to be
decent at diffusing traffic early and not rely on wide roads to do that job.)

~~~
mjevans
Have they fixed the problem where that 'ideal route' even includes not merging
left to pass around a stalled lane? It's been seemingly forever since I built
a city.

------
zoom6628
Its principles also hold up for drivers in China. Guess the chinese love
copying american things right down to driving just as badly :-D

Anyway, jokes aside, this has a lot more uses than proof we are all bad
drivers. I can this being a great simple way to show queues in a
factory/shop/office coffee machine . Awesome work and i wish i as 5% as good
at coding to be able to do this when on holiday. On my hols i would be lucky
to get past hello world. Kudos to this guy.

------
striking
Set the driver reaction time to 500ms, with 90 cars launched a minute, and
you'll see what my daily commute is like.

~~~
gerdesj
Eastbourne at rush hour?

(It's a rubbish joke:
[http://www.bbc.co.uk/news/magazine-27066299](http://www.bbc.co.uk/news/magazine-27066299))

------
fatdog
Love how sitting in the passing lane at a speed %10 lower than target causes
cascading collisions.

If driving causes cancer, at least the people who drive in the passing lane
(the left one) deserve it.

------
zodPod
This is cool! I always wanted to make something like this for intersections
and randomize the response time in an effort to prove whether or not people
who pull out slower at red lights cause others to miss the lights or not. Just
a neat experiment as well!

~~~
catshirt
why would you need to simulate that problem? the answer is yes- you can miss a
green light if someone accelerates too slowly.

------
robmiller
I'm most interested by the umlaut in the domain name that apparently isn't
respected by HN. Also a way to restrict your domain name to certain keyboards
(easily)?

------
shocks
It'd be interesting to implement lane discipline and see how one bad driver
effects the rest.

~~~
ajmurmann
Yes, please! I suspect lack of lane discipline to be the single biggest
disadvantage US freeways have to American's. I would love to test that at
least via simulation. I would expect that two lanes with lane discipline are
better than three without. Potentially even better than four.

~~~
JadeNB
> I suspect lack of lane discipline to be the single biggest disadvantage US
> freeways have to American's.

I guess one of 'US' or 'American' is a typo, but (not being an international
driver) I'm not sure which one ….

------
legohead
Nice. I've wanted to do something like this, as I have a theory about the car
pool lanes being worse for traffic. When traffic is bad, car pool lanes are
just as backed up typically.

When someone wants to get in the car pool lane upon entering the highway, they
tend to do so fairly quickly. This can cause a shockwave as someone flies from
one side of the highway to the other. The same thing can happen in the
opposite direction when a carpool lane driver needs to get off, and this issue
is compounded even more since you can't always (legally) exit the carpool
lane.

So I thought it'd be interesting to play with a simulator like this,
add/remove carpool lanes, or lanes altogether, and see what results.

~~~
mjevans
In the uncounted thousands of hours of driving on the freeway in my life thus
far, I've observed:

* Drivers will improperly idle in a lane they feel safe in, refusing to keep right except to pass (this is actually state law where I live).

* Any deviation from a straight, flat, roadway (corners, hills, dips, anything) will cause the flow to slow; even when you can proxy the status of the roadway in front by the tail-lights of all the lanes of cars who /can/ see.

* Apparently no 'big' city anywhere balances jobs and housing. Cities too small to balance anything are also generally too small to notice the issue. (I say this because it seems like everyone is economically incentivized to drive as far as they can possibly stand from work for the cheapest housing; clearly there isn't enough housing near jobs to keep those costs competitively low.)

~~~
tbihl
On your first point, that's the norm in my driving (most of both US coasts.)
I've sometimes wondered what the saturation level is where the left lane
should just be another lane to increase steady state flow rate. I guess it's
when the lane becomes too crowded to cycle properly.

On your second point, I've always just assumed that that was a tall car thing
because I figured they probably get more uncomfortable cornering. The same way
I probably seem irrational when I speed around pickup trucks: they probably
fail to recognize that their driving in front of me is like putting a wall in
my face (and unlike semi trucks the drivers are no better than the rest of the
people on the road.)

On your third point, the US has baked in too many policies that are
prohibitive to sensible development patterns. The implicit subsidies for low
density living and the federally insured mortgage cone to mind as two of the
worst.

------
paulsutter
A bug in this simulator is that new settings apply only to newly-launched
cars, incrasing the chaos as you explore a range of options. Increased speed
shows an exaggerated immediate increase in crashes, decreased speed causes an
exaggerated decrease in crashes, and so on.

The sensible conclusion here is that human drivers could be banned in order to
safely minimize travel times (much faster reaction times, lower variance in
speed).

------
Silvanm
Glad to see my first post on HN to receive such positive feedback. I guess
I'll post my vacation projects regularly if they are appreciated :-)

If you want to see a more scientific approach at the subject I recommend
looking at [http://traffic-simulation.de/](http://traffic-simulation.de/)

------
nercht12
What about prioritizing vehicles? Imagine - if all cars drive along in a well-
defined path, will we end up with making assassinations easier? That's a
stretch (I mean, not like exceptions couldn't be made for POTUS and such), but
I wonder about what sort of consequences would arise from having predictable
traffic.

------
mwexler
No post on traffic is complete without a reference to the original "traffic
hobbyist": [http://trafficwaves.org/](http://trafficwaves.org/) from Jan 1998.

------
mpnordland
Simple Highway _Collision_ Simulator. Could be a great little game with an
educational bent. Personally I set reaction time to 0 and jacked everything
else to max. Then I spammed the launch button.

------
hacker314159
Really cool project. I wonder if transportation agencies would want to use
something like this for studying traffic.

------
cpeterso
If you launch new cars too quickly, they start blowing up. :)

------
sparky_
Very interesting, for sure.

