• 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.

Aberro

Private
14 Badges
Jul 5, 2024
24
5
  • Crusader Kings II
  • Cities: Skylines
  • Cities: Skylines - After Dark
  • Cities: Skylines - Snowfall
  • Stellaris
  • Hearts of Iron IV: Cadet
  • Hearts of Iron IV: Colonel
  • Cities: Skylines - Mass Transit
  • Age of Wonders III
  • Cities: Skylines - Green Cities
  • Cities: Skylines - Parklife
  • Cities: Skylines Industries
  • Prison Architect
  • Crusader Kings III
This mod allows you to configure hundreds of available parameters for pathfinding algorithm, at next to zero performance cost.

After first start with this mod enabled, the mod will create a config file, where it will save all available pathfinding parameters. This should work with any version of the game, at least if data structures wouldn't change. The data consists of six dictionaries, three of which are default data combined from game value and updated each run, and three other dictionaries are for modified values. There's dictionaries for car values, pedestrian values and train values. Each dictionary have a list of prefab names followed by pathfinding costs. The number of costs varies per dictionary, as trains have much less options than cars or pedestrians. Each cost consists of four values: Time, Behavior, Money and Comfort. I'm not yet sure how exactly each one works, but it seems that for each one the greater the value the less likely a given entity will choose the route. It's recommended to use behavior cost by default, but you are free to experiment.

To modify values, copy prefab name and the cost you want to change into the same non-default dictionary, for example:

Code:
"CarData": {
    "Tiled Street Pathfind - Tram": {
      "DrivingCost": {
        "Time": 0,
        "Behaviour": 10,
        "Money": 0.01,
        "Comfort": 0.1
      },
    },
  },

Keep in mind that all four cost values should be set. It's not strictly required to read the file, but if you do not set these values, they will be set to 0 by mod next time the game is started. I can't change that, as the mod uses in-game saving algorithm. As for costs in a prefab - you don't have to set them all, unset values will automatically reset to null value, which means that in-game value should remain unmodified.

It's strongly suggested to save your configuration file to some custom folder, as configuration in the game's user folder overridden often and you may lost your custom configuration.
 
Btw, I tried to update the mod, both new version and update configuration, but toolchain says some unknown error. So... I'm out of ideas how to do that. Even just publishing it wasn't without errors, but in that case removing long description did helped.
 
Btw, I tried to update the mod, both new version and update configuration, but toolchain says some unknown error. So... I'm out of ideas how to do that. Even just publishing it wasn't without errors, but in that case removing long description did helped.
have you tried getting modders and CO help on discord? :)
 
I wouldn't be so sure about time, money and comfort, since it's pathfinding algorithm. And worst of all - it's a fuzzy algorithm. So, it doesn't just searches for best way, it searches for some good enough way with a bit of randomness, and for me it's hard to tell how exactly it works. But the behavior part, looking at default values, is the default and most used way to determine avoidance. I.e. the higher the value - the more likely entity will avoid given segment of the network. Avoid, but not forbid, so, the higher the behavior the less likely someone will choose that segment.
I understand what “time”, “money”, and “comfort” costs represent, but do you know what a “behavior” cost is?
 
  • 1Like
Reactions:
@Aberro
I see, thank you. I recall a dev diary mentioning that cims value time, money, and comfort differently depending on their age. So maybe “behavior” is a way to scale all three values for a segment up or down relative to the rest of the network. Just speculation on my part.
 
Honestly, starting this mod I hoped that there would be more prefabs. Because it's really annoying how cars choose narrow 2 lane road over 6 way roads just because it's slightly shorter. Completely unrealistic behavior. But sadly, prefabs do not differentiate between specific kind of road, just the general kind - is it a street, a road, or a highway, and that's it. I might try to find out how specifically this works and if there's maybe still a way to prefer wider roads, either by injecting more prefabs (which is unlikely) or by modifying the pathfinding algorithm itself (unlikely too, but because of complexity and inefficiency), or by some other way (this is more likely, but quite undetermined).
But at least in it's current form I can push cars slightly more towards highways, and reduce unsafe maneuvers quite a bit, and also cover PedestrianPathfinding mod functionality entirely, with more customization (I configured my pedestrians to do occasional jaywalking, like one in a few hundreds, instead of completely forbidding it), albeit, in much less convenient way (the config file in json... but I'm also thinking about changing it to some spreadsheet format; as for UI I'm not good with it, and this mod would require quite extensive UI to cover hundreds of parameters).
 
  • 1Like
Reactions:
I've been running into the issue of most cims moving in only using cars and choke up my roads. With this mod can you bias them more toward using public transport? I heard somewhere that they severely dislike PT transfers, is there a way to lessen that penalty/cost?
 
I've been running into the issue of most cims moving in only using cars and choke up my roads. With this mod can you bias them more toward using public transport? I heard somewhere that they severely dislike PT transfers, is there a way to lessen that penalty/cost?
I'm not sure yet. Possibly? Probably? It might depend on pathfinding implementation specifics, or they might just generate at random on the border, I'm not sure. What I can tell for sure is that it'd be impossible to modify only arriving citizens, modified costs will apply everywhere.

I want to look at pathfinding, but for now I'm trying to revive the Speed Limit Editor mod first, so that I can modify road speeds. And sadly, since the game UI is on react and typescript, it's way outside of my qualification, so I have to figure out literally everything the hard way.

But I hope at some point to be able to write a mod that will allow me to debug pathfinding, to reset the route specifically, so with this pathfinding costs mod, I would be able to modify values, reset the route and look how and why things are working the way they are.

Until then, sadly, I don't even know what half of the values in the config are for.
 
I'm not sure yet. Possibly? Probably? It might depend on pathfinding implementation specifics, or they might just generate at random on the border, I'm not sure. What I can tell for sure is that it'd be impossible to modify only arriving citizens, modified costs will apply everywhere.

I want to look at pathfinding, but for now I'm trying to revive the Speed Limit Editor mod first, so that I can modify road speeds. And sadly, since the game UI is on react and typescript, it's way outside of my qualification, so I have to figure out literally everything the hard way.

But I hope at some point to be able to write a mod that will allow me to debug pathfinding, to reset the route specifically, so with this pathfinding costs mod, I would be able to modify values, reset the route and look how and why things are working the way they are.

Until then, sadly, I don't even know what half of the values in the config are for.
I see. I think I'm ok with applying the modified costs everywhere. Which prefabs and costs would I need to modify?
 
I see. I think I'm ok with applying the modified costs everywhere. Which prefabs and costs would I need to modify?
Again, I don't know exactly, but I'd guess that you could try "Public Transport Pathfind" prefabs, in pedestrian group. But that might be about public-transport exclusive lanes. But your guess would be as good as mine.
 
Hi, Aberro. Would it be possible to post some example prefabs along with an explanation so it's easier to get an idea on what some values would change? What's the minimum or maximum of the values and what would increase driving using like an American city or what would be the settings for a European city to disincentive driving, and etc.
 
Hi, Aberro. Would it be possible to post some example prefabs along with an explanation so it's easier to get an idea on what some values would change? What's the minimum or maximum of the values and what would increase driving using like an American city or what would be the settings for a European city to disincentive driving, and etc.
I wouldn't recommend using this mod in general, as it's in very early stage and as I've said I haven't figure out a lot of things. I'm slowly working my way, not on this mod, though, I'm updating Speed Limit Editor by SwiftCobra, but nonetheless, I'm learning modding for CS2 in general, UI, systems and such, and traffic in particular. I took a quick look at pathfinding in the game, but it's not trivial, so I'm still not sure how it works. And after Speed Limit Editor, I plan to make a debugging features in this mod to do debug and experimentation on different values, different prefabs and different entities, and maybe implement more features and modify pathfinding. Maybe. Because in the end I want to fix pathfindind as much as anyone. But I'm doing it in my free time.

So, as of now, I can only say that the minimum is 0, but this limit is by common sense, and there's probably no maximum.
But in case someone else could do testing using this mod and report how different values change the behavior - it would be really helpful and could save a lot of time.