Install Steam
login
|
language
简体中文 (Simplified Chinese)
繁體中文 (Traditional Chinese)
日本語 (Japanese)
한국어 (Korean)
ไทย (Thai)
Български (Bulgarian)
Čeština (Czech)
Dansk (Danish)
Deutsch (German)
Español - España (Spanish - Spain)
Español - Latinoamérica (Spanish - Latin America)
Ελληνικά (Greek)
Français (French)
Italiano (Italian)
Bahasa Indonesia (Indonesian)
Magyar (Hungarian)
Nederlands (Dutch)
Norsk (Norwegian)
Polski (Polish)
Português (Portuguese - Portugal)
Português - Brasil (Portuguese - Brazil)
Română (Romanian)
Русский (Russian)
Suomi (Finnish)
Svenska (Swedish)
Türkçe (Turkish)
Tiếng Việt (Vietnamese)
Українська (Ukrainian)
Report a translation problem
They managed to get the pathfinder separated out (which is a minor miracle considering Unity APIs aren't thread-safe) and the entire routes of vehicles and cims is determined in that pathfinder. Problem is, because all the paths are planned in advance, and can't refer to other traffic conditions, all the vehicles just choose the same shortest routes (with some pseudo-randomisation thrown in to mix things up a little). That's why you end up with traffic all using same lane.
When it comes to actually rendering the vehicles driving on roads, stopping at junctions, etc., they also had to perform minor miracles to make that work without literally tanking the fps to zero.
First trick they use is 'leader cars' - where cars on same route work out which car is at the front and then all the others, 'follower cars', re-use the vehicle AIs of the leader car, greatly reducing load on vehicle AIs.
The next trick, 'vehicle grids', deal with collisions. In order to allow all vehicles to be processed in a single iteration of the vehicle list, which is done to ensure maximum branch predication and minimum memalloc and gc, ie. max performance, there's no easy way to say "what car is on this road segment or junction I'm about to drive in to", because doing so would require multiple iterations of the vehicle list and again tank fps to zero. So they have a 'vehicle grid' which is basically just a crazy mathematical way of quickly working out what vehicles are in a certain 'square' on the map by multiplexing the x,y co-ords of all vehicles in to a single number that's encoded in such a way you can use bitwise maths (very fast) to later locate the vehicles....
So the vehicle AIs are iterating the vehicles in turn, and for each one that's moving has to check if it collides with another using the vehicle grid. Sometimes the vehicle at the back moves first (it's earlier on the list being iterated) and doesn't detect the front one, and all sorts of other fringe cases, which leads to momentary vehicle collisions and the AI just stops whatever appears to be the one at the back and lets the others keep moving. That's why you get weird stuff happening at junctions, because what exactly is "the back" when vehicles collide from different directions?
When you say 'Is making a 4-phase traffic light so damn hard to do' the answer is, obviously, "No - so long as you don't care about tanking fps to zero". When it comes to doing it without tanking fps, that takes an insane amount of effort considering how already-overloaded the game is due to the extensive amount of simulation it's doing in a single CPU core / thread.
If you want more control over traffic lights, then use TM:PE which allows you to control each lane at a junction independently. It will tank performance, but thanks to ~4 years of continual development[github.com], not to zero. Interestingly enough, the team are looking to use 'vehicle grid' technique but applied to other stuff like eg. 'network grid' and 'parking grid'. So we might be able to make performance a little better even with the timed traffic lights.
https://steamcommunity.com/sharedfiles/filedetails/?id=1588131325
https://steamcommunity.com/sharedfiles/filedetails/?id=1798966916
https://steamcommunity.com/sharedfiles/filedetails/?id=1795143727
https://steamcommunity.com/sharedfiles/filedetails/?id=1790807987
https://steamcommunity.com/sharedfiles/filedetails/?id=1745929667
https://steamcommunity.com/sharedfiles/filedetails/?id=1654870620
A simple Move lt work
https://steamcommunity.com/sharedfiles/filedetails/?id=1647262643
Because a large number of users are on potato computers.
Thank you for your detailed explanation from software side of things! I'm not very studied in the aspects of the foundations of C:S, so this was educational.
One question though, if an aftermarket modding can incorporate all sorts of timed lights and phases into this game(and, as you said, while not tanking the performance), can't the devs take a leaf out of their book and make the lights at least sensible? Not even expecting the flexibility of TMPE - I just want protected lefts and non-conflicting light plans.
The vehicle collision algorithm would also be a lot more hassle-free if the intersections' lights were designed to not allow for any vehicle routes to overlap at all(like IRL), so I'm a bit confused.
Does this have to do with the efforts of the TMPE dev teams' efforts being stolen, or that this function is only possible by modding, and not from the ground-up without performance hits?
Thank you again for your detailed answer.
Technically, yes, and they'd do a better job than modders. But is it worth it for them to do that? Probably not - they're not going to get any extra money out of doing it. Might as well spend time on DLCs and start working on whatever their next game is. There's also the risk to sales if it goes wrong - like if it grinds on potato computers they lose vastly more users and thus less DLC sales. Again, better to leave what's already done as it is, and focus on DLCs to bring in extra revenue while they develop next game.
> I fail to follow, beacuse if so how does TMPE make it possible, on those said 'potatoes'?
It doesn't, it grinds like crazy on potatoes. But at least with a mod the user can easily just remove it if they decide framerate is more important than fancy traffic lights. If it was baked in to game, user would basically be stuck with pure lag.
Also, I'd like to think they are investing resource in developing C:SL v2 with a new game engine that will drastically extend what can be done with the game. Although from what I've seen them say at some AMAs and other interviews I suspect they are probably wanting to try other genres as all they've done so far is transport / city builder type games.
Also, I think, for most people buying this game, it's to scratch a creative itch that city builders provide. Traffic is only one factor in that equation. I see loads of people spend ages detailing, or creating assets, or modding, or doing crazy public transport setups, or just generally enjoying the game in other ways, despite the issues with vanilla traffic and the low frame rate.
Out of all the 92 games I have, C:SL is the only one I keep coming back to because there's just so much room for creativity. Admittedly, I'm not sure that would be the case without the workshop, but then again I doubt any company could create so many features and assets without having to find all sorts of evil ways to extort more money from players.
I applaud your commitment to the game, as well as your patience.
I often use TMPE but I do not bother with the parking AI, perhaps I'll try it again. It does make a city seem much more realistic with having full cap parks everywhere.
Perhaps one day you might get to enjoy an upgrade to your system.
I always have TMPE loaded and I'm using the LABS version. I just remember on a very large city getting very close to the maximum allowed parked cars when using the Parking AI. It is not as though there is a percentage amount to use for that, it is either totally on or off.
I'll probably use it again now.