Pathfinder penalty for road vehicles (r17469)
Moderator: OpenTTD Developers
Pathfinder penalty for road vehicles (r17469)
This is not exactly a new patch, but one I made some time ago that never got much attention. I didn't make an own thread for it back then, so I'm catching up with that now.
Newest version: r17469
The newest version works with both NPF and YAPF as pathfinder for road vehicles.
If you want to customize the settings (e.g. via console), they are named as follows:
for NPF: pf.npf.npf_road_vehicle_penalty
for YAPF: pf.yapf.road_vehicle_penalty
---
Older versions:
r17455
---
Description:
What does it do?
In technical terms, it adds a new pathfinder penalty to YAPF (note: current version also NPF) that applies to all tiles that have a roadvehicle on them which goes in the same direction as the planned path of the currently pathfinding vehicle.
In simple terms, it makes vehicles avoid routes where there already are vehicles. This means that if there are multiple routes with roughly the same distance available, the vehicle will choose the one with less traffic.
Here's an example:
It's a simple sort-of-highway (only that the lanes are not LLRR but LRLR), and as you can see some vehicles are using the left, some the right lane, despite having the same destination. I hope some of you will enjoy this patch. I'd say it's 50-50 eyecandy and useful. Eyecandy because it (hopefully) makes traffic look more natural; useful because it might help avoid some congestions if a fleet of buses with the same orders won't always take one specific, predetermined path, but diversify a bit...
Newest version: r17469
The newest version works with both NPF and YAPF as pathfinder for road vehicles.
If you want to customize the settings (e.g. via console), they are named as follows:
for NPF: pf.npf.npf_road_vehicle_penalty
for YAPF: pf.yapf.road_vehicle_penalty
---
Older versions:
r17455
---
Description:
What does it do?
In technical terms, it adds a new pathfinder penalty to YAPF (note: current version also NPF) that applies to all tiles that have a roadvehicle on them which goes in the same direction as the planned path of the currently pathfinding vehicle.
In simple terms, it makes vehicles avoid routes where there already are vehicles. This means that if there are multiple routes with roughly the same distance available, the vehicle will choose the one with less traffic.
Here's an example:
It's a simple sort-of-highway (only that the lanes are not LLRR but LRLR), and as you can see some vehicles are using the left, some the right lane, despite having the same destination. I hope some of you will enjoy this patch. I'd say it's 50-50 eyecandy and useful. Eyecandy because it (hopefully) makes traffic look more natural; useful because it might help avoid some congestions if a fleet of buses with the same orders won't always take one specific, predetermined path, but diversify a bit...
Last edited by Roujin on 08 Sep 2009 10:49, edited 4 times in total.
Re: Pathfinder penalty for road vehicles (r17438)
So its something like this (I'm not sure):
This train picks the path with less traffic instead of waiting until the first path is open, may have been glitched because trains have no orders
This train picks the path with less traffic instead of waiting until the first path is open, may have been glitched because trains have no orders
- Attachments
-
- Peter Transport, 7th Jun 2065.png (15.7 KiB) Viewed 5334 times
Re: Pathfinder penalty for road vehicles (r17438)
Uhm, I wrote "road vehicles" in several places, most noticeable in the title of this thread. How come you're expecting this patch to do anything on trains? 

Re: Pathfinder penalty for road vehicles (r17438)
I was simply suggesting that trains already preform the same feature, and comparing this patch to the behavior of trains.
Not the reaction I was aiming for.
Not the reaction I was aiming for.
Re: Pathfinder penalty for road vehicles (r17438)
Mmm, like it, does it produce noticeable differences in towns? Is there any significant performance hit? And does it take into account trams?
Re: Pathfinder penalty for road vehicles (r17438)
This seems very useful. A road vehicle that is loading/unloading in a drive through station in the same direction than the current vehicle gives penalties too?. I think that could help with the problem reported at FS#1944.
Edit: Another question... why do you increment SAVEGAME_VERSION to 200 instead of by 1?. And in the SDT_CONDVAR you use 100 instead of 200.
Edit: Another question... why do you increment SAVEGAME_VERSION to 200 instead of by 1?. And in the SDT_CONDVAR you use 100 instead of 200.
Last edited by Terkhen on 07 Sep 2009 10:07, edited 1 time in total.
Spanish translation of OpenTTD
Extended heightmaps
Have fun, don't quarrel too much and add as many advanced settings as you can.
Extended heightmaps
Have fun, don't quarrel too much and add as many advanced settings as you can.
Re: Pathfinder penalty for road vehicles (r17438)
It should, as there is another a route, with less trafficTerkhen wrote:This seems very useful. A road vehicle that is loading/unloading in a drive through station in the same direction than the current vehicle gives penalties too?. I think that could help with the problem reported at FS#1944.

Looks very promising

My patches: Day length (new concept), Conditional loading, Auto separation, Unload all adds Leave empty, Better statue placement (in trunk)
My abandoned patches: Speed limits for RVs, Day length (old concept)
My abandoned patches: Speed limits for RVs, Day length (old concept)
Re: Pathfinder penalty for road vehicles (r17438)
Probably depends on the value you set it to. Choose a high value and your vehicle will take any detour if it sees another vehicle in front of it (shy vehicleZephyris wrote:Mmm, like it, does it produce noticeable differences in towns?

Good question. I haven't done any big-scale tests with the patch. In theory, it shouldn't be too bad - iirc YAPF doesn't run continuously, but only when needed (e.g. on a crossing where the vehicle could take different routes). Then, I'm using the existing check VehicleFromPos on each tile the pf walks - it kind of depends on how well this function works. It's not working naively, but using some sort of hash, so I assume it's more or less efficient.Is there any significant performance hit?
If anyone makes a big-scale game with this and notices performance hits (outside the usual), please inform me

Not tested, but it should.And does it take into account trams?
edit: tested, works like a charm

The cost is calculated for road stops too, so it should work. However, I do not know the details of the mentioned problem - maybe my patch helps, maybe not. But please see for yourself, if it does help "accidentally", that's fineTerkhen wrote:This seems very useful. A road vehicle that is loading/unloading in a drive through station in the same direction than the current vehicle gives penalties too?. I think that could help with the problem reported at FS#1944.

The first one - well, why not. Saves me from changing it every time trunk bumps. Of course if it were to be included to trunk, I'd change it to +1 instead.Edit: Another question... why do you increment SAVEGAME_VERSION to 200 instead of by 1?. And in the SDT_CONDVAR you use 100 instead of 200.
The second one is a bug, thanks for noticing. Will fix soon.
PS: I made this last mistake (not updating saveload properly) on all three patches of mine I updated yesterday night. Gah

Last edited by Roujin on 07 Sep 2009 14:28, edited 2 times in total.
Re: Pathfinder penalty for road vehicles (r17438)
Here is a new version for r17455.
Fix: Loading trunk games. (thanks Terkhen)
Fix: Loading trunk games. (thanks Terkhen)
Re: Pathfinder penalty for road vehicles (r17438)
The drive-through stop problem is *almost* completely solved with this patch. The real problem remains, but since road vehicles tend to choose empty stops they seem to work way better. I will do more serious tests later, but I don't remember being able to put 200 coal trucks between two maximum sized road stops in a 128x128 scenarioRoujin wrote:The cost is calculated for road stops too, so it should work. However, I do not know the details of the mentioned problem - if vehicles ignore penalties on going to road stops and just take the closest part they can find, my patch won't be of any help. But please see for yourself, if it does help "accidentally", that's fineTerkhen wrote:This seems very useful. A road vehicle that is loading/unloading in a drive through station in the same direction than the current vehicle gives penalties too?. I think that could help with the problem reported at FS#1944.

Spanish translation of OpenTTD
Extended heightmaps
Have fun, don't quarrel too much and add as many advanced settings as you can.
Extended heightmaps
Have fun, don't quarrel too much and add as many advanced settings as you can.
Re: Pathfinder penalty for road vehicles (r17455)
I was thinking of something like that yesterday while looking at my buses bloked by a full loading AI, this one will be very usefull 

-
- Chief Executive
- Posts: 658
- Joined: 11 Nov 2007 12:06
- Contact:
Re: Pathfinder penalty for road vehicles (r17455)
Dose it work with all path finders or just YAPF?
For Community Integrated Version http://code.google.com/p/civopenttd/
Re: Pathfinder penalty for road vehicles (r17455)
Currently only YAPF is supported.
Which pathfinder are you using? A different one?
Is there a good reason not to use YAPF (for road vehicles)?
Which pathfinder are you using? A different one?
Is there a good reason not to use YAPF (for road vehicles)?
Re: Pathfinder penalty for road vehicles (r17455)
Some cool screenshots from how this great patch works:
- Attachments
-
- Prundwood Transport, 13th Mar 2025#1.png (2.77 KiB) Viewed 4978 times
-
- Prundwood Transport, 13th Mar 2025.png (32.61 KiB) Viewed 4978 times
Re: Pathfinder penalty for road vehicles (r17455)
Anyway, here's a new version (for r17469) that also works with NPF. Beware that npf got its own setting, not shared with the one from YAPF.
Note: This version works with both NPF and YAPF, despite the name
Note: This version works with both NPF and YAPF, despite the name
Last edited by Roujin on 08 Sep 2009 10:43, edited 1 time in total.
-
- Chief Executive
- Posts: 658
- Joined: 11 Nov 2007 12:06
- Contact:
Re: Pathfinder penalty for road vehicles (r17469)
I just askinged about it becuse a patch has to keep all settings in the game working
I did not know if it would break/ not work at all
Thank you very much
I did not know if it would break/ not work at all
Thank you very much
For Community Integrated Version http://code.google.com/p/civopenttd/
Re: Pathfinder penalty for road vehicles (r17469)
I see. Well I think regarding pathfinders this is not necessarily a must - there are already things in trunk that only work with YAPF, not NPF (nor original PF). But in any case now my patch works with both YAPF and NPF (sh... I just noticed I named the patch "yapf_...", that's a misnomer).
I think YAPF and NPF should suffice. Original PF is strongly discouraged to use anyway. And I don't know at all how it works and if it's even possible to apply any penalties or such.
I think YAPF and NPF should suffice. Original PF is strongly discouraged to use anyway. And I don't know at all how it works and if it's even possible to apply any penalties or such.
-
- Chief Executive
- Posts: 658
- Joined: 11 Nov 2007 12:06
- Contact:
Re: Pathfinder penalty for road vehicles (r17469)
Thank now all we need for roads is to make 1way roads use both sides but that would be a patch in its own
For Community Integrated Version http://code.google.com/p/civopenttd/
Re: Pathfinder penalty for road vehicles (r17469)
Such a patch exists.2007Alain2007 wrote:Thank now all we need for roads is to make 1way roads use both sides but that would be a patch in its own
Re: Pathfinder penalty for road vehicles (r17469)
He means that in a one way road, vehicles only use one side of the road, leaving the other only to overtake vehicles. This patch allows vehicles to choose between different roads, but they still only use one side of the road.
Spanish translation of OpenTTD
Extended heightmaps
Have fun, don't quarrel too much and add as many advanced settings as you can.
Extended heightmaps
Have fun, don't quarrel too much and add as many advanced settings as you can.
Who is online
Users browsing this forum: No registered users and 27 guests