Cities: Skylines

Cities: Skylines

Traffic Manager + Improved AI
 This topic has been pinned, so it's probably important
fadster  [developer] 22 Feb, 2016 @ 10:37pm
Original Description
I really like the new AI from Traffic++ but I desperately needed the ability to modify lane arrows and priority signs. After some digging in the code, I found a relatively easy way for Improved AI to conform to the changes made in Traffic Manager. With these mods combined, you can now edit traffic lights, lane arrows and priority signs on top of the excellent new AI provided by jfarias.

This mod is compatible with saved games produced by the original Traffic Manager. I believe it should also work with the ones made by Traffic Manager Plus, although I haven't tested that. Also, you should be able to use Traffic++ in ghost mode if you need to. I think it's possible to remove this dependency, I might eventually write a mod for that sometime soon. I've played a little with timed traffic lights but haven't tested saving and loading, let me know if they work or not. Also, I now realize I never tried to clear traffic, so this may or may not work at the moment. If it doesn't, I'd advise not to use it because I have no idea what it does to the AI!

EDIT: Clear traffic seems to work fine. By the way, your public transport figures drop to zero when you clear traffic.

I've tested this for a couple of days and it seems no new problems have been introduced by combining both mods. I think the new AI is the best we've had so far. The only issue I can see is a tendency for cars to want to use the same lane from time to time. However, it doesn't take much time for the AI to recover and the jams to clear up. While testing, I found two parameters in Improved AI that can be tweaked to modify this behavior. From the comments in the code, I see jfarias didn't have time to experiment much with those. It looks like the default values aren't optimal and could be contributing to this lane usage problem. I've had much better results by tweaking them a bit.

I left the values as they were in the original code, but I've exposed them so you can modify them in-game if you have ModTools installed. The variables are:

PathManager.CustomPathFind.m_congestionCostFactor
PathManager.CustomPathFind.m_minLaneSpace

When there is less than m_minLaneSpace available in a lane, the AI considers it as "congested" and multiplies its cost for path finding by m_congestionCostFactor. The default values are 5 for lane space (from the comments, this is for a "car of length 5" but the units are not specified) and 3 for congestion cost factor. From my experiments, it seems traffic behaves much better with values as high as 30 for lane space and 125 for cost factor. Try some values and post the results, I'm curious to see what works for you guys. If there's enough interest, I'll try to add a simple GUI for everybody to edit these values easily.

EDIT: Actually, increasing the cost factor too much is not a good idea. It will, in particular, wreak havock in your bus lines, as busses will take insane detours between stops to avoid congestion. In fact, a neat experiment to try is to fiddle around with these values with the public transit info view on. You'll see right away the effects on the path finding as lines will adjust soon after you change the values. At the moment, I seem to be having good results with minimum lane space of 15 and default cost factor of 3.

There are many more features that can be added to this mod. I'd like to add the lane changer from Traffic++ in addition to the one provided by Traffic Manager. This will allow finer tuning for more complex intersections. One particular application would be roundabouts, where ideally people should be staying in their lanes when merging into the roundabout instead of crossing lanes.

One final note. All credit for the original code goes to CBeThaX and jfarias. These guys have produced some outstanding work indeed. All I've done is make their code cooperate to produce something I believe will benefit everybody.

Enjoy!

P.S. You must deactivate all other versions of Traffic Manager as well as Improved AI before activating this mod.

Source code available here.[github.com]