logoalt Hacker News

Art of Roads in Games

567 pointsby linolevanyesterday at 9:05 PM184 commentsview on HN

Comments

rob74today at 8:26 AM

> I think roads lie at the heart of every city builder. It’s the fabric on which cities are built.

To paraphrase the article, this is what urban planners have nightmares about. Roads (as in: things made for cars) aren't the fabric of a city, streets (as in: things made not only for cars, but also for pedestrians, cyclists, public transport etc.) are. See also: https://en.wikipedia.org/wiki/Stroad

show 5 replies
devnullbraintoday at 2:00 PM

>You see, the shapes of roads in real life come from an underlying essential fact: the wheel axles of a vehicle. No matter how you drive a car, the distance between the left and right wheels remains constant. You can notice this in tyre tracks in snow or sand. Two perfectly parallel paths, always the same distance apart maintaining a consistent curved shape.

Emphasis mine - that's not really true

- Cars have differentials, so the wheel speed can differ between wheels

- Steering geometry isn't parallel! The tyres turn a different amount when you turn the wheel

- Unless you're going in a straight line, cars don't go where the tyres point! Tyres 'pull' the car towards their slip angle

What you will actually see in tracks in snow or sand is non-parallel tracks, describing curves of different radii. You can also see this in racetracks, where the path more closely resembles the limits of car physics without care for passenger comfort or tyre wear. The example 'fail' image looks not dissimilar from a hairpin turn.

show 3 replies
acheriontoday at 5:10 AM

The author might get a kick out of an upcoming game called Junxions, which is a sandbox game to just do that... create road junctions.

The subreddit is here: https://www.reddit.com/r/Junxions/

Sure they teased that they've made their own solution, but I think Junxions should scratch the itch of most of us here interested in this kind of game.

show 2 replies
abcde666777today at 4:06 AM

There's so many things in games that are taken for granted at play time but which actually take a lot of thinking and work to get right. Roads for instance aren't something which your typical player will look too closely at... but they will notice if they look or behave in a way that seems wrong.

I've been playing Kingdom Come 2 of late, and I find it's natural to just kind of take the world they've created for granted - just like we do the real world. But when you actually stop and look you have to consider that every one of the finely crafted details was built by someone's sweat and tears, be it artists, programmers, or designers at edit time.

No wonder it's an industry of crunch, the work involved can be uniquely daunting.

show 4 replies
curiousObjecttoday at 1:45 PM

This is interesting, I look forward to reading more. But I think it’s wrong, if you want to represent reality.

Real cities were all built in the past, for older vehicles, which moved at different speeds, and were controlled by drivers with different goals from today’s drivers.

So, if your game has bad and unsafe road designs, which have been partly retrofitted to reduce the worst problems, then that is accurate.

A game with optimal roads is not an accurate simulation of reality.

A professional modern road designer will simulate the expected movement of vehicles through a new or redesigned road, to try to discover major problems.

They look for problems with turning radius, visibility, stopping distances, and interactions with other road users.

I believe that a game designer could offer to do the same.

The game could draw a good algorithmic road shape first. But next offer the player an option to run a simulation of individual traffic movements, to discover serious issues, and let the player know about problems.

To the OP, I suggest this simulation approach, not trying to discover flawless algorithms. That’s not how it happens in the real world.

Several comments have suggested similar issues.

show 1 reply
hirako2000today at 4:00 AM

Articles like these are the reason I continue to check hackernews.

Author please keep writing.

show 1 reply
Arn_Thortoday at 8:20 AM

"Do 99% of city-builder players care what shape the corner radius of the intersection has? Most likely, no."

Finally, I am part of the 1%!

show 1 reply
frou_dhtoday at 3:51 PM

In 3D games, something that's key for roads to look/feel realistic is to have small amounts of banking here and there all over the place - as opposed to just having a crude categorisation where there are flat roads on one hand and ramps on the other.

If you don't do that then large parts of the game world end up seeming like ice rinks with roads painted on them.

spacedcowboytoday at 8:38 AM

Bézier curves - specifically for things like roads where you want a single definition of the road/path and an extended image that obeys that path, turning it into a pair of offset-béziers aren't the easiest thing to work with. They collapse to a visually unattractive solution at extreme boundary conditions (such as a tight turn)

You can see it in one of his examples where the bézier curve has an inflexion point which crosses over itself on a sharp bend. I ran into this while writing Azoth [1] last year, when wanting to be able to overlay paths with blending into the background at the sides, and curving around existing features on a game map. To solve the problem, I simplified it, and there's an (animated) example of how I got it working here [2]

[1] https://github.com/ThrudTheBarbarian/Azoth

[2] https://github.com/ThrudTheBarbarian/Azoth/blob/main/Documen...

zabzonktoday at 2:01 AM

Be like the Romans - make them all straight lines :-)

Of course the Romans didn't give a shit who's property rights they might be violating. I live in Lincolnshire UK, where Roman roads are still used. The last one that got changed was years ago when they had to put a kink in Ermine Street (now the A15) at RAF Scampton when they extended the runway to accommodate Vulcan bombers.

show 2 replies
Notatheisttoday at 11:31 AM

In my early days someone told me generating roads is a non-trivial problem and I thought that was bollocks so I spent 4 months smashing my head against a wall to prove them wrong!

>A clothoid gradually increases curvature over distance.

This seems complete overkill? I remember smoothing between tangents of two circles to mostly solve roundabouts. I had to cheat for 3+ lane roundabouts but it worked for any semi-realistic road.

>Just simple rules stacking on each other that result in beautiful patterns. I can’t explain why, but seeing those structures always felt good.

I think in 2026 it's safe to blame your autism. I do. Nobody likes Factorio because it's a good game. We're here for the lines and grids.

noduermetoday at 7:04 AM

Ahhh.. this is a writer after my own heart. Absolutely brilliant write-up. I had the same obsession with roads, from SimCity onward; they're the circulatory system of any city, and never in the history of cities or the history of circulatory systems have the vessels been straight lines. The streets of a European or Asian village usually tell a story about how roads were built over the fastest footpath from the outskirts to the center, then over time amended to go around some buildings that were built in the way. Whereas roads in rural parts where I come from run in long straight lines and then suddenly swerve to get around a piece of land that a farmer wouldn't sell. But grids only exist in some parts of the few cities that were built mostly by colonial powers, or developed later with master planning. And even those grids usually split from their original orientation to becoming north-south at some point in in the city's development, leading to the interesting downtown triangle blocks of cities like Portland, San Francisco, Los Angeles, Seattle, New York. Other cities started to grid around their core footpath villages, like Madrid, Barcelona.

The cities I find the most interesting (for roads) are the ones which kept gridding out in new directions to follow the course of a river. Cities like Buenos Aires, New Orleans, and Saigon, where the original paths followed curves around the river bends, resulting in multiple intersecting grids.

The intersections and division boulevards between grids are, of course, the most beautiful and architecturally interesting parts of any city. They are where the blocks are strangely shaped and the buildings can't be rectangular, and usually where every inch of land is at a premium as well. It would be nice if a city-builder could simulate that aspect of urban growth: The shift from village center to grid, and old grid to new grid.

show 1 reply
serious_angeltoday at 2:08 AM

Thank you very much... Ineffably magnificent, as always...

Related: https://www.pushing-pixels.org/2014/04/04/the-craft-of-scree... (The craft of screen graphics and movie user interfaces - interview with Jorge Almeida...)

vanaurtoday at 11:07 AM

One may also be interested in Egregoria (https://github.com/Uriopass/Egregoria). This is a 3D city builder written in Rust, with particular attention to roads. I have never used the project (because it would not be useful for what I usually do), but I have been following its development at the beginning and I think it is quite cool stuff.

muzanitoday at 2:50 AM

I was fascinated by them since reading a guide for Cities: Skylines that said that roads were like trees. There's a trunk that moves large amounts of nutrients and little branches that distribute the nutrients to the leaves. Such simple rules, but such complex and deterministic results.

czheotoday at 4:35 AM

I studied urban planning back in the university and one of the classes was road design. Though I forgot most, one part of the class was about how to design roads with curves that's safe for cars. This post just brought that memory back to me.

antiftoday at 3:17 AM

One game that had a different perspective (first person mmo), but a fun network of road building in a simulated wilderness .. Wurm Online

dandelliontoday at 4:10 PM

Not just roads! I made a small train game for a game jam, and I used splines for the tracks to get them done quickly. It did the job, but they looked wrong to me. So I revisited it a few weeks later and looked into arcs and clothoids as well. I replaced the splines with some basic code using arc and the result looked so much better.

austin-cheneytoday at 11:35 AM

I have never seen a Texas style mixmaster, or stack exchange, in a game. Here is an irregular example:

https://en.wikipedia.org/wiki/Spaghetti_Junction

show 1 reply
heyitssimtoday at 4:06 AM

My version of OP's roads problem is blob autotiling - how tiles connect to their neighbors. 256 possible neighbor combinations reduce to 47 valid patterns once you realize corners only matter when both adjacent edges are present. You paint a semantic type like "wall", the system resolves the right tile from those 47 patterns - but painting one tile cascades outward, neighbors re-resolve, which triggers their neighbors, and you're tracking stale state to keep it all consistent. Same underlying problem as road segments affecting connected intersections.

I've been trying to make this as easy as possible for non technical people to draw terrain in craftmygame (the game engine I'm building) here's what the terrain painting looks like in the editor so far : https://youtu.be/bFrUYM2t3ZA?si=tw1LqBWR7Uyn08lR&t=37

inflam52today at 3:56 AM

Timely article for me! I just went through this in my little SimCity remake for MicroPython:

https://github.com/chrisdiana/TinyCity/blob/6c3a7337788655b5...

JKCalhountoday at 1:55 PM

Love these deep dives—perfect HN fodder. Add to that articles like this also on the front page today: "Algorithmically Finding the Longest Line of Sight on Earth," "Tesselation Kit"…

HN, keep being HN! We love you.

Garetoday at 5:40 AM

> And they are also… a math nightmare. Differential geometry. Integrals. Oh my… Which is probably why most games don’t even dare.

Wonder if cubic parabola (used by some railways, and visually near indistinguishable from clothoid) has easier maths.

show 2 replies
interloxiatoday at 9:08 AM

In my next game, Canalpunk, I'm planning to keep with bezier splines. The self intersection of the paths will make the disaster system more interesting.

xixixaotoday at 8:58 AM

I’ve been kinda obsessed with getting clothoids to work in a railway track editor. It’s easy enough to build out of clothoids into empty space, but connecting tracks is where it gets really hard.

For now all I have to share is this explainer I made some years ago: https://xixixao.github.io/euler-spiral-explanation/

show 2 replies
pmontratoday at 7:30 AM

The bit about the clothoid finally made me understand the odd shape of highway junctions. I always wondered why they want me to enter turns fast and then slow down progressively until the turn becomes a new straight. Unfortunately sometimes that straight is the highway, and they should give us plenty of space to build up speed and match the traffic inside the highway. Sometimes they do, sometimes they don't.

show 1 reply
sam_lowry_today at 8:44 AM

At some point I Google Maps was using Bézier curves for roads, but then they started approximating even roundabouts with polylines, and this looks unbelievably clunky.

Some manager at Google should have gotten an appraisal for removing proper curves from Maps, because... who cares, they do not need them on US streets.

ChicagoDavetoday at 8:57 AM

Now imagine a city where there is no human driven transport: pedestrians, bicyclists, and automated vehicles exist in different constructs above and below ground and never cross each other’s path completely negating the inherent risks. No roads. No parking. Just fluid, cohesive movement.

bombcartoday at 2:27 AM

Another aspect of these games is the subtle scale issues that aren’t readily apparent - even the newest biggest city simulators are fractions of the size of a real city.

Road and rail curves are massive and it’s hard to understand just how big they are without having to actually walking them.

show 2 replies
jet98today at 8:14 PM

Streets ahead

jak6jaktoday at 5:38 AM

Everyone is raving about this article. It feels so much like a tease to me. Maybe I'm just impatient idk.

show 1 reply
BrtBytetoday at 11:58 AM

Nope, most players won't consciously care but systems built on the right constraints tend to feel right even when you don't know why

show 1 reply
ramongatoday at 1:21 PM

If you liked this you'll love playing mini motorways (available in many platforms including mobile/ipad)

smhinseytoday at 4:45 AM

This is a really interesting approach but I'm curious to see how it translates to the actual mesh extrusion, or whatever 3d technique they adopt. It's relatively easy to do this in 2d, it's the 3d solution that accommodates terrain variation that introduces the real explosion of complexity

orbit7today at 7:16 AM

Can relate the fascination with roads I use to like drawing them loads as a kid. I find Satisfactory the most satisfying for building transport systems (and building generally) your work incorporated into a mod for that would be really cool.

show 1 reply
pixl97today at 6:33 PM

>Does everything I just rambled about matter? Do 99% of city-builder players care what shape the corner radius of the intersection has? Most likely, no. Then why bother?

To me, yes, then again I may end up with a basement full of model trains when I'm old.

Still annoys me to no end when the game model builds something unrealistic and would be an absolute traffic nightmare in the real world.

raincoletoday at 3:31 AM

Cool shit!

> Do 99% of city-builder players care what shape the corner radius of the intersection has? Most likely, no.

Maybe not... but out of all the players who care corner radius of roads in games, 99% of them probably are into city-builder!

show 1 reply
voodooEntitytoday at 8:37 AM

Always thought some streets in city builders just are a bit tooooo off :D

Very nice article - good read !

Wistartoday at 7:34 AM

[Adds “clothoid” to vocabulary]

heliumteratoday at 2:25 AM

The tech seems really cool, but the road showed in the examples is not any less insane, like, why?

show 2 replies
cookiengineertoday at 11:15 AM

As a German, pretty much all of the intersections shown in the article trigger me quite a bit. In Germany, there's a standardized Autobahnkreuz [1] most of the time. If it's a construction site or an incompleted Autobahn intersection, it's usually called Autobahndreieck (and not -kreuz) on the signs.

This way, all drivers can already sort themselves onto the matching lanes without even having seen the signs yet.

The standardized Autobahnkreuz also has always identical ways to change directions, where the left lane leaving the highway is made for change in opposite direction or for turnarounds. So if you took the wrong exit, you can always save yourself by just driving that lane 3 times across the bridge.

If the traffic increases over time, usually the right exit lanes are doubled and that fixes the problem.

Rarely though there's different setups like around the A61 and A67 where the traffic around and towards Frankfurt city / airport is too huge for that system.

[1] https://de.wikipedia.org/wiki/Autobahnkreuz

show 1 reply
tgtweaktoday at 1:46 PM

Cool - now make it into a mod for cities skyline :)

Ahnonimustoday at 12:44 PM

Minecraft

e2319685today at 9:42 AM

Daniel

adamrezichtoday at 5:37 PM

Very disappointed that this article ends just before it starts to get into anything concrete and interesting—I'm working on solving (a simplified subset of) very similar problems for a game I'm working on, and would love to learn more about the author's approach!

chonglitoday at 2:47 AM

I love SimCity 2000 and these roads look really cool but I'd really like to see a city-builder go in a different direction.

One of the biggest problems with North American cities is their endless, car-centric suburban sprawl. SimCity games may be really fun to play but they seem to reinforce this problem and anyone who grows up playing them will not learn about alternatives for more livable cities.

New Urbanism, traditional neighbourhood design, streetcar suburbs, one-way streets, bike paths, walking paths, mixed-zone walkable villages (light commercial with residential), smaller single-family houses and duplexes, triplexes, houses behind houses. Many of these are older and more traditional techniques to yield higher density neighbourhoods without building up to large apartment buildings.

It would be really cool to see a game that focused more on creating these kinds of realistic and aspirational living spaces instead of the usual cookie-cutter suburbs linked up by huge roads and a large downtown core.

show 9 replies