Dear Devs: A proposal for improved (and performant) traffic lane distribution AI

  • We have updated our Community Code of Conduct. Please read through the new rules for the forum that are an integral part of Paradox Interactive’s User Agreement.

Morwynd

Private
Mar 19, 2015
23
14
So the problem with "smart lane selection" is that having every car constantly making such pathfinding calculations would cripple performance.

So how we can distribute lane usage better, in a way that still allows for a one-time calculated route at departure time?

I think a way that could work, is to randomly assign each vehicle a "lane preference number", that is then applied every time multiple appropriate lanes are available.

Eg: Assign every vehicle a random number between 1 and 60 (60 being the lowest common multiple of 2, 3, 4, 5, 6 which represent the possible number of lane options). Then every time the vehicle must choose a lane during the pathfinding calculation, use that number to select one.

So say there's 2 lanes making a left turn at an intersection. Cars with a number between 1-30 would choose the first lane, and 31-60 would use the second one. if there's 3 choices, the split is 1-20, 21-40, 41-60. If there's 4 choices, 1-15, 16-30, 31-45, 46-60... and so on for 5 and 6 lane choices.

(You want a single number that can be applied consistently to many choices instead of randomizing for each intersection, otherwise you'll get crazy weaving between intersections as everyone is switching lanes willy nilly.)

I have used randomization approaches like this to solve similar "congestion" problems in software before... typically for an event scheduler where too many things are trying to happen at the same time (so randomized time offsets instead of lane selection, but same general principle).
 
  • 13
Reactions:

Matt8D

Corporal
1 Badges
Mar 15, 2015
43
31
  • Cities: Skylines
The only issue I could see is the min/maxers complaining. Introducing some un-optimization sounds like a closer step towards realism, and I would love the challenge of dealing with bad drivers :p
 

Morwynd

Private
Mar 19, 2015
23
14
This is such an elegant solution (at face value) that i doubt this thread will have much activity in it :p

Also, I just realized I probably should have posted in the "Suggestions & feedback" sub-forum. Whoops! First day on the forums here. :eek:o Perhaps a kind moderator could move this thread there if they see this.

The only issue I could see is the min/maxers complaining. Introducing some un-optimization sounds like a closer step towards realism, and I would love the challenge of dealing with bad drivers :p

UN-optimization you say? ;) When I see a million cars using the same turning lane when there's two available, that's what I consider un-optimal (in terms of usage of space). :)
 

Brabbit1987

Second Lieutenant
3 Badges
Mar 9, 2015
115
1
  • Knights of Pen and Paper +1 Edition
  • Warlock: Master of the Arcane
  • Cities: Skylines
I don't think the game itself has much of a problem with AI selecting the lanes they need to go in. The issue comes about when there is only 1 lane on a 6 lane road that can be used to make a turn when everyone wants to make that turn.

So a very simple solution to this problem is to increase the lanes that can be used. We have already seen work around from other using road behaviors. 6 lane road splits into 3 one way 2 lane roads. 2 lanes turn right, 2 lanes turn left, and 2 lanes go straight.

So the solution is to allow players to alter the lanes directions themselves. so they can dedicate as many lanes as they need.

Though I suppose you could combine both solutions, but I doubt the lanes being chosen is causing any sort of performance issues because the real calculations are happening when it's choosing the best route to take. In which case, that isn't going to change because they still need to calculate that.

Of course I am not a programmer and maybe I just am misunderstanding something.
 

Morwynd

Private
Mar 19, 2015
23
14

MarshalN

Colonel
1 Badges
May 6, 2003
1.080
17
Visit site
  • Crusader Kings II
Well the reason for that behaviour illustrated in the thread you linked to is because of subsequent turns they need to make, and they are planning ahead for it by getting in the right lane now. It's not realistic driving behaviour but it's what the AI seems to do. Your solution would need to override that lane selection algorithm in order to work, and then they will have to readjust to the fact that they now want to take a left after that right and so they need to switch lanes - not sure if it will be good or bad for traffic in game.
 

Matt8D

Corporal
1 Badges
Mar 15, 2015
43
31
  • Cities: Skylines
Well the reason for that behaviour illustrated in the thread you linked to is because of subsequent turns they need to make, and they are planning ahead for it by getting in the right lane now. It's not realistic driving behaviour but it's what the AI seems to do. Your solution would need to override that lane selection algorithm in order to work, and then they will have to readjust to the fact that they now want to take a left after that right and so they need to switch lanes - not sure if it will be good or bad for traffic in game.

The thing is, when there's multiple lane turns onto the same road, theoretically each lane is the same speed-to-destination. But the AI doesn't pick either one, it just pick the closest one. It'll change to that lane a set number of intersections or distance from the turn.

Since more than one lane can be the same speed-to-destination, varying the cars choice of lane randomly could end up making traffic more efficient while keeping each car on the optimal route. Even if it's just blind randomness it could still work.
 

Person012345

Field Marshal
92 Badges
Jan 27, 2010
2.594
914
  • Cities: Skylines - After Dark
  • Europa Universalis IV: Res Publica
  • Victoria: Revolutions
  • Semper Fi
  • Victoria 2: A House Divided
  • Victoria 2: Heart of Darkness
  • Stellaris - Path to Destruction bundle
  • Europa Universalis IV: Pre-order
  • Age of Wonders III
  • Stellaris: Synthetic Dawn
  • Cities in Motion 2
  • Europa Universalis IV: Cossacks
  • Cities: Skylines - Snowfall
  • Europa Universalis IV: Mare Nostrum
  • Stellaris
  • Stellaris: Galaxy Edition
  • Crusader Kings II: Reapers Due
  • Crusader Kings II: Jade Dragon
  • Europa Universalis IV: Third Rome
  • Hearts of Iron III: Their Finest Hour
  • Crusader Kings II: Legacy of Rome
  • Crusader Kings II: Charlemagne
  • Crusader Kings II: The Old Gods
  • Crusader Kings II: Rajas of India
  • Crusader Kings II: The Republic
  • Crusader Kings II
  • Crusader Kings II: Sons of Abraham
  • Crusader Kings II: Sword of Islam
  • Europa Universalis IV
  • Europa Universalis IV: Art of War
  • Cities in Motion
  • Europa Universalis IV: Conquest of Paradise
  • Europa Universalis IV: Wealth of Nations
  • Europa Universalis IV: Call to arms event
  • For the Motherland
  • Leviathan: Warships
  • Hearts of Iron III
  • Stellaris: Leviathans Story Pack
  • Cities: Skylines - Natural Disasters
  • Hearts of Iron IV: Together for Victory
  • Crusader Kings II: Monks and Mystics
  • Hearts of Iron IV: Colonel
  • Hearts of Iron IV: Cadet
  • Stellaris Sign-up
  • Stellaris: Necroids
  • Crusader Kings II: Conclave
  • Crusader Kings II: Way of Life
  • Europa Universalis IV: El Dorado
  • 500k Club
  • Victoria 2
Also, I just realized I probably should have posted in the "Suggestions & feedback" sub-forum. Whoops! First day on the forums here. :eek:o Perhaps a kind moderator could move this thread there if they see this.



UN-optimization you say? ;) When I see a million cars using the same turning lane when there's two available, that's what I consider un-optimal (in terms of usage of space). :)
Yes, but a min-maxer will have min-maxed the road system that the cars will be using the lanes perfectly. Throw some randomisation in there and it'll upset their balance, whilst making everyone else much happier.
 

Iche_Bins

Lt. General
111 Badges
Feb 5, 2006
1.217
1.049
  • March of the Eagles
  • For the Motherland
  • Hearts of Iron III
  • Hearts of Iron III: Their Finest Hour
  • Hearts of Iron III Collection
  • Heir to the Throne
  • Europa Universalis III Complete
  • Knights of Pen and Paper +1 Edition
  • Lead and Gold
  • Leviathan: Warships
  • The Kings Crusade
  • Magicka
  • Majesty 2
  • For The Glory
  • Europa Universalis III Complete
  • Europa Universalis IV: Res Publica
  • Victoria: Revolutions
  • Europa Universalis: Rome
  • Rome Gold
  • Semper Fi
  • Sword of the Stars
  • Sword of the Stars II
  • The Showdown Effect
  • Victoria 2
  • Victoria 2: A House Divided
  • Europa Universalis 4: Emperor
  • Commander: Conquest of the Americas
  • Hearts of Iron II: Armageddon
  • Cities in Motion
  • Cities in Motion 2
  • Crusader Kings II
  • Crusader Kings II: Charlemagne
  • Crusader Kings II: Legacy of Rome
  • Crusader Kings II: The Old Gods
  • Crusader Kings II: Rajas of India
  • Crusader Kings II: The Republic
  • Crusader Kings II: Sons of Abraham
  • Crusader Kings II: Sunset Invasion
  • Crusader Kings II: Sword of Islam
  • A Game of Dwarves
  • Darkest Hour
  • Deus Vult
  • Dungeonland
  • East India Company Collection
  • Europa Universalis III
  • Divine Wind
  • Europa Universalis IV
  • Europa Universalis IV: Art of War
  • Europa Universalis IV: Conquest of Paradise
  • Europa Universalis IV: Wealth of Nations
Also, I just realized I probably should have posted in the "Suggestions & feedback" sub-forum. Whoops! First day on the forums here. :eek:o Perhaps a kind moderator could move this thread there if they see this.

Its probably easier to just open the same thread there again...
 

EvilTom

Lt. General
57 Badges
Dec 15, 2014
1.271
512
  • Crusader Kings II: Charlemagne
  • Stellaris: Synthetic Dawn
  • Stellaris - Path to Destruction bundle
  • Crusader Kings II: Reapers Due
  • Stellaris: Galaxy Edition
  • Stellaris
  • Europa Universalis IV: Mare Nostrum
  • Cities: Skylines - Snowfall
  • Europa Universalis IV: Cossacks
  • Cities: Skylines - After Dark
  • Cities: Skylines Deluxe Edition
  • Sword of the Stars
  • Europa Universalis IV: Res Publica
  • Europa Universalis IV: Wealth of Nations
  • Crusader Kings II
  • Crusader Kings II: Legacy of Rome
  • Crusader Kings II: The Old Gods
  • Crusader Kings II: Rajas of India
  • Crusader Kings II: The Republic
  • Crusader Kings II: Sons of Abraham
  • Crusader Kings II: Sunset Invasion
  • Crusader Kings II: Sword of Islam
  • Europa Universalis IV: Art of War
  • Europa Universalis IV: Call to arms event
  • Europa Universalis IV: Conquest of Paradise
  • Crusader Kings II: Monks and Mystics
  • Stellaris: Megacorp
  • Cities: Skylines Industries
  • Crusader Kings II: Holy Fury
  • Stellaris: Distant Stars
  • Cities: Skylines - Parklife
  • Cities: Skylines - Parklife Pre-Order
  • Stellaris: Apocalypse
  • Stellaris: Humanoids Species Pack
  • Crusader Kings II: Jade Dragon
  • Cities: Skylines - Green Cities
  • Crusader Kings III
  • Cities: Skylines - Mass Transit
  • Europa Universalis IV
  • Cities: Skylines - Natural Disasters
  • Stellaris: Leviathans Story Pack
  • Stellaris: Digital Anniversary Edition
  • Cities: Skylines
  • Hearts of Iron IV: Colonel
  • Hearts of Iron IV: Cadet
  • Stellaris: Galaxy Edition
  • Europa Universalis IV: El Dorado
  • Crusader Kings II: Way of Life
  • Europa Universalis IV: Common Sense
  • Crusader Kings II: Conclave
Would you not get the same problem when say you have a highway going off to an offramp? You'd just end up with people blocking ALL lanes instead of the one they want to come off at?
 

playn2

Private
33 Badges
Feb 16, 2015
17
3
  • Stellaris: Distant Stars
  • Cities: Skylines - Mass Transit
  • Surviving Mars
  • Cities: Skylines - Green Cities
  • Stellaris: Humanoids Species Pack
  • Stellaris: Apocalypse
  • Surviving Mars: Digital Deluxe Edition
  • Cities: Skylines - Parklife Pre-Order
  • Cities: Skylines - Parklife
  • Stellaris - Path to Destruction bundle
  • Shadowrun: Hong Kong
  • Cities: Skylines Industries
  • Imperator: Rome Deluxe Edition
  • Imperator: Rome
  • Cities: Skylines - Campus
  • Stellaris: Ancient Relics
  • Crusader Kings III
  • Ancient Space
  • Cities: Skylines - Natural Disasters
  • Stellaris: Leviathans Story Pack
  • Stellaris Sign-up
  • Stellaris: Galaxy Edition
  • Stellaris: Galaxy Edition
  • Stellaris: Galaxy Edition
  • Stellaris
  • Cities: Skylines - Snowfall
  • Cities: Skylines - After Dark
  • Cities: Skylines Deluxe Edition
  • Cities: Skylines
  • Crusader Kings II: The Old Gods
  • Crusader Kings II
  • Cities in Motion 2
  • Cities in Motion
I have to echo in saying great idea. Right now the single line result is hampering my enjoyment of the game. Hope the devs are really test your theory and see if it produces a better/realistic result.
 

Morwynd

Private
Mar 19, 2015
23
14
Well the reason for that behaviour illustrated in the thread you linked to is because of subsequent turns they need to make, and they are planning ahead for it by getting in the right lane now.

Yes that is correct, it would alter the current behaviour where the lane selection appears to be solely based on the next turn they need to make.

It's about increasing intersection throughput and mitigating the giant backups that result. With a single lane being used, the amount of cars that pass through the intersection on each green light is very low.
 

Azurespecter

Influencer Manager
Paradox Staff
36 Badges
Aug 14, 2013
595
813
twitter.com
  • Crusader Kings II
  • Europa Universalis IV: Rights of Man
  • Stellaris: Galaxy Edition
  • Stellaris
  • Europa Universalis IV: Cossacks
  • Europa Universalis IV: Res Publica
  • Europa Universalis IV: Call to arms event
  • March of the Eagles
  • Europa Universalis IV: Art of War
  • Europa Universalis IV: Wealth of Nations
  • Europa Universalis IV: Conquest of Paradise
  • Europa Universalis IV
  • Steel Division: Normandy 44
  • Cities: Skylines - Mass Transit
  • Steel Division: Normandy 44 Deluxe Edition
  • Surviving Mars
  • Cities: Skylines - Green Cities
  • Europa Universalis IV: Cradle of Civilization
  • Surviving Mars: Digital Deluxe Edition
  • Cities: Skylines - Parklife
  • Europa Universalis IV: Dharma
  • Surviving Mars: First Colony Edition
  • Prison Architect
  • Stellaris Sign-up
  • Hearts of Iron IV Sign-up
  • Stellaris: Galaxy Edition
  • Europa Universalis IV: Mare Nostrum
  • Europa Universalis IV: Common Sense
  • Europa Universalis IV: El Dorado
  • Cities: Skylines
  • Warlock: Master of the Arcane
  • Stellaris: Galaxy Edition
  • Europa Universalis IV: Third Rome
  • Cities: Skylines - Snowfall
  • Cities: Skylines - After Dark
  • Cities: Skylines Industries
First, thanks for making such a well thought out suggestion. Forums need good communicators like yourself.

Just so I can understand more clearly, are you saying that each car should have a pre-designated lane that they will always use? So what happens when you have two lanes that can turn left onto a two-way street, so 50% of traffic is using each turning lane, but then after both lanes turn left they both need to turn left again but this time there is only one turning lane?

Then what you would have is one lane trying to merge into the other, which would cause massive backups anyways. The difference being is that now the entire two-way street is backed up, preventing cars from turning left AND right, rather than the current system which only blocks the left.

Make sense?
 

AustinPowersFas

First Lieutenant
16 Badges
Jan 13, 2010
254
48
  • For the Motherland
  • Hearts of Iron III Collection
  • Cities in Motion 2
  • Europa Universalis IV
  • Victoria: Revolutions
  • Victoria 2
  • Victoria 2: A House Divided
  • Victoria 2: Heart of Darkness
  • Warlock: Master of the Arcane
  • 500k Club
  • Cities: Skylines
  • Stellaris
  • Hearts of Iron IV: Cadet
  • Cities: Skylines - Mass Transit
  • Age of Wonders III
  • Victoria 3 Sign Up
I don't think the game itself has much of a problem with AI selecting the lanes

I disagree. The problem lies exactly there. Either they are bugs or it is intended, either way it should be changed.

Situation (sadly no screen):
We have a 3-lane one-way road (highway) splitting into 2 separate 2-lane one-way roads (still following...?) like this: Y.
The one-way highway part has 2 lanes for right, and 2 for left (the middle lane having both possibilities).
Now EVERY vehicle, either going left or right, is using the far RIGHT lane of the one-way highway road. Even tho on this lane is only an arrow drawn for going right.
The other 2 lanes are NOT used.

If you follow this or not, in both cases it makes no sense...
 

playn2

Private
33 Badges
Feb 16, 2015
17
3
  • Stellaris: Distant Stars
  • Cities: Skylines - Mass Transit
  • Surviving Mars
  • Cities: Skylines - Green Cities
  • Stellaris: Humanoids Species Pack
  • Stellaris: Apocalypse
  • Surviving Mars: Digital Deluxe Edition
  • Cities: Skylines - Parklife Pre-Order
  • Cities: Skylines - Parklife
  • Stellaris - Path to Destruction bundle
  • Shadowrun: Hong Kong
  • Cities: Skylines Industries
  • Imperator: Rome Deluxe Edition
  • Imperator: Rome
  • Cities: Skylines - Campus
  • Stellaris: Ancient Relics
  • Crusader Kings III
  • Ancient Space
  • Cities: Skylines - Natural Disasters
  • Stellaris: Leviathans Story Pack
  • Stellaris Sign-up
  • Stellaris: Galaxy Edition
  • Stellaris: Galaxy Edition
  • Stellaris: Galaxy Edition
  • Stellaris
  • Cities: Skylines - Snowfall
  • Cities: Skylines - After Dark
  • Cities: Skylines Deluxe Edition
  • Cities: Skylines
  • Crusader Kings II: The Old Gods
  • Crusader Kings II
  • Cities in Motion 2
  • Cities in Motion
Based on the scenario you stated, we would be assuming that all vehicles in the traffic jam are basically going to the same area. If so be the case, I can easily see where the choke point is (you second left turn) and resolve it. In the current state, I have no idea if the problem is truly a road capacity issue as the roads are not being utilized to its fullest potential. Using the OPs suggestion, it would be somewhat simple to try and resolve the problem you stated...add a second lane to the second turn. Currently, that simple option does not exist.

Hope I also make sense but I would like to hear the thoughts of the OP on this as well.

Edit: This was in response to the Azurespecter's scenario above.
 

RebelBinary

Private
9 Badges
Mar 19, 2015
14
16
  • Cities in Motion 2
  • Cities: Skylines
  • Cities: Skylines - After Dark
  • Stellaris
  • Stellaris - Path to Destruction bundle
  • Surviving Mars
  • Stellaris: Humanoids Species Pack
  • Stellaris: Apocalypse
  • Prison Architect
I agree this is a better solution, because A) it's more realistic B) it shows you where the congestion is at it's source based on the build up of vehicles trying to get into the one lane.

It's also the most complained about thing in most reviews and most ppl who aren't aware of how the A.I works think it's because the game is broken
 

Emre Yigit

Creeping out of Covid hibernation
73 Badges
Jun 13, 2001
5.462
3.803
  • Cities: Skylines - Snowfall
  • Victoria 2
  • Victoria 2: A House Divided
  • Victoria 2: Heart of Darkness
  • 500k Club
  • Cities: Skylines
  • Cities: Skylines Deluxe Edition
  • Europa Universalis IV: El Dorado
  • Europa Universalis IV: Pre-order
  • Pride of Nations
  • Europa Universalis IV: Common Sense
  • Cities: Skylines - After Dark
  • Europa Universalis IV: Cossacks
  • Semper Fi
  • Europa Universalis IV: Mare Nostrum
  • Stellaris
  • Stellaris: Galaxy Edition
  • Stellaris: Galaxy Edition
  • Hearts of Iron IV Sign-up
  • Hearts of Iron IV: Cadet
  • Hearts of Iron IV: Colonel
  • Europa Universalis IV: Rights of Man
  • Stellaris: Digital Anniversary Edition
  • Stellaris: Leviathans Story Pack
  • Hearts of Iron IV: Together for Victory
  • Battle for Bosporus
  • Europa Universalis IV: Wealth of Nations
  • Crusader Kings II: Charlemagne
  • Crusader Kings II: Legacy of Rome
  • Crusader Kings II: The Old Gods
  • Crusader Kings II: Rajas of India
  • Crusader Kings II: The Republic
  • Crusader Kings II: Sons of Abraham
  • Crusader Kings II: Sunset Invasion
  • Crusader Kings II: Sword of Islam
  • Europa Universalis III
  • Europa Universalis IV
  • Europa Universalis IV: Art of War
  • Europa Universalis IV: Conquest of Paradise
  • Crusader Kings II
  • Europa Universalis IV: Call to arms event
  • For the Motherland
  • Hearts of Iron III
  • Hearts of Iron III: Their Finest Hour
  • Hearts of Iron III Collection
  • Heir to the Throne
  • Europa Universalis III Complete
  • March of the Eagles
  • Europa Universalis III Complete
  • Europa Universalis IV: Res Publica
A) Just so I can understand more clearly, are you saying that each car should have a pre-designated lane that they will always use? B) So what happens when you have two lanes that can turn left onto a two-way street, so 50% of traffic is using each turning lane, but then after both lanes turn left they both need to turn left again but this time there is only one turning lane?

Then what you would have is one lane trying to merge into the other, which would cause massive backups anyways. The difference being is that now the entire two-way street is backed up, preventing cars from turning left AND right, rather than the current system which only blocks the left.

Make sense?

Speaking on behalf of OP without any authorisation whatsoever:

A) Given a certain number of lanes in any one direction, yes.

B) That would, I think, still be preferable to the current system. I can think of three ways around the problem off-hand, only one of which involves the introduction of new road types. :)
 
Last edited: