Dynamically choose new path to station if present path is too slow
Moderator: OpenTTD Developers
Dynamically choose new path to station if present path is too slow
Hi,
is there any way to change the present path of a bus. So imagine the bus drives from A to B and recognizes that there is a traffic jam or something. Is there any way, that it can then take another route?
Until know I see no way but I also don't really know, how the "max speed not greater than" condition in the conditional orders work. So maybe someone can explain those to me?
Thanks in advance!!!
is there any way to change the present path of a bus. So imagine the bus drives from A to B and recognizes that there is a traffic jam or something. Is there any way, that it can then take another route?
Until know I see no way but I also don't really know, how the "max speed not greater than" condition in the conditional orders work. So maybe someone can explain those to me?
Thanks in advance!!!
Re: Dynamically choose new path to station if present path is too slow
no, the pathfinder is not really capable of detecting traffic jams.
Re: Dynamically choose new path to station if present path is too slow
Perhaps it's an idea to maintain a value for each tile (or direction on it) and slowly decrement it as the tile is attended by the tile loop. Each vehicle occupying the tile causes the value to increase by 1 (to an arbitrary maximum). The value then ends up representing how busy the tile is.
The pathfinder could check that value every time it has a choice. This value could be added as an additional penalty for the pathfinder, thus making routes around the "jam" more attractive.
The tile loop can be used to lower the value representing how busy a certain piece of infrastructure is. An additional map view could be used to assist players in figuring out which areas are busiest (and thus need more or smarter infrastructure).
The pathfinder could check that value every time it has a choice. This value could be added as an additional penalty for the pathfinder, thus making routes around the "jam" more attractive.
The tile loop can be used to lower the value representing how busy a certain piece of infrastructure is. An additional map view could be used to assist players in figuring out which areas are busiest (and thus need more or smarter infrastructure).
Re: Dynamically choose new path to station if present path is too slow
Ok that helps me a lot! Am I right, that for every vehicle the pathfinder gets called at every tick?
So that at every tick the path can eventually be planned new?
EDIT: And it is not possible to redirect a vehicle using the conditional orders? Maybe by using the "if maximum speed < x" condition?
So that at every tick the path can eventually be planned new?
EDIT: And it is not possible to redirect a vehicle using the conditional orders? Maybe by using the "if maximum speed < x" condition?
Re: Dynamically choose new path to station if present path is too slow
Does anybody know when and how many times the pathfinder gets called?
Thanks in advance!
Thanks in advance!
Re: Dynamically choose new path to station if present path is too slow
every time the vehicle arrives at a crossing.
Re: Dynamically choose new path to station if present path is too slow
The pathfinder gets called when a vehicle gets a choice to make.
Re: Dynamically choose new path to station if present path is too slow
And YAPF chooses the route with the fewest accumulated penalties right?
Does it take the pure distance into account?
Thanks
Does it take the pure distance into account?
Thanks
- planetmaker
- OpenTTD Developer
- Posts: 9432
- Joined: 07 Nov 2007 22:44
- Location: Sol d
Re: Dynamically choose new path to station if present path is too slow
'distance' is an abstract thing with a path finder. The path with the least cost is chosen - that includes distances (as every tile has a certain penalty) as well as other penalties.Noltibus wrote:And YAPF chooses the route with the fewest accumulated penalties right?
Does it take the pure distance into account?
Thanks
Every tile has its own penalty, depending on how the track goes:
Code: Select all
/** Length (penalty) of one tile with YAPF */
static const int YAPF_TILE_LENGTH = 100;
/** Length (penalty) of a corner with YAPF */
static const int YAPF_TILE_CORNER_LENGTH = 71;
Code: Select all
yapf.rail_firstred_penalty = 1000
yapf.rail_firstred_exit_penalty = 10000
yapf.rail_lastred_penalty = 1000
yapf.rail_lastred_exit_penalty = 10000
yapf.rail_station_penalty = 1000
yapf.rail_slope_penalty = 200
yapf.rail_curve45_penalty = 100
yapf.rail_curve90_penalty = 600
yapf.rail_depot_reverse_penalty = 5000
yapf.rail_crossing_penalty = 300
yapf.rail_look_ahead_max_signals = 10
yapf.rail_look_ahead_signal_p0 = 500
yapf.rail_look_ahead_signal_p1 = -100
yapf.rail_look_ahead_signal_p2 = 5
yapf.rail_pbs_cross_penalty = 300
yapf.rail_pbs_station_penalty = 800
yapf.rail_pbs_signal_back_penalty = 1500
yapf.rail_doubleslip_penalty = 100
yapf.rail_longer_platform_penalty = 800
yapf.rail_longer_platform_per_tile_penalty = 0
yapf.rail_shorter_platform_penalty = 4000
yapf.rail_shorter_platform_per_tile_penalty = 0
yapf.road_slope_penalty = 200
yapf.road_curve_penalty = 100
yapf.road_crossing_penalty = 300
yapf.road_stop_penalty = 800
yapf.road_stop_occupied_penalty = 800
yapf.road_stop_bay_occupied_penalty = 1500
yapf.maximum_go_to_depot_penalty = 2000
OpenTTD: manual | online content | translations | Wanted contributions and patches
#openttdcoop: blog | wiki | public server | DevZone | NewGRF web translator
DevZone - home of the free NewGRFs: OpenSFX | OpenMSX | OpenGFX | Swedish Rails | OpenGFX+ Trains|RV|Industries|Airports|Landscape | NML
Re: Dynamically choose new path to station if present path is too slow
You guys are amazing!!!
Is there a line of code where it is checked if the vehicle reached a crossing and then the pathfinder is called?
Thanks!
Is there a line of code where it is checked if the vehicle reached a crossing and then the pathfinder is called?
Thanks!
Re: Dynamically choose new path to station if present path is too slow
And, as I'm looking through the source code, in which file did you find the variable YAPF_TILE_LENGTH?
Thanks in advance!!!
EDIT: Got it
Thanks in advance!!!
EDIT: Got it
Re: Dynamically choose new path to station if present path is too slow
What exactly do you mean with "Tile loop". Can you explain that to me?Expresso wrote:Perhaps it's an idea to maintain a value for each tile (or direction on it) and slowly decrement it as the tile is attended by the tile loop. Each vehicle occupying the tile causes the value to increase by 1 (to an arbitrary maximum). The value then ends up representing how busy the tile is.
I know I ask a lot but I really need you guys.
- HackaLittleBit
- Director
- Posts: 550
- Joined: 10 Dec 2008 16:08
- Location: tile 0x0000
Re: Dynamically choose new path to station if present path is too slow
You have to read a couple of documents to get a better understandig about the game.
This is the holy grale of the game.
Transport_Tycoon_Deluxe_savegame_internals
in the docs folder study landscape.html and landscape_grid.html and landscape_externals.html
Now about the 'Tile loop'.
You have to look at the game as a 3 dimentional array.
length and width of the map and then deep (8 x 8 bits + 16 bits ,see landscape_grid.html)
Look for RunTileLoop()(genworld.cpp, landscape.cpp, openttd.cpp)
This is the loop that updates the information that is stored in each individual tile in the game.
This is the holy grale of the game.
Transport_Tycoon_Deluxe_savegame_internals
in the docs folder study landscape.html and landscape_grid.html and landscape_externals.html
Now about the 'Tile loop'.
You have to look at the game as a 3 dimentional array.
length and width of the map and then deep (8 x 8 bits + 16 bits ,see landscape_grid.html)
Look for RunTileLoop()(genworld.cpp, landscape.cpp, openttd.cpp)
This is the loop that updates the information that is stored in each individual tile in the game.
Re: Dynamically choose new path to station if present path is too slow
The tile loop goes repeatedly over the map and handles things like grass growth, house construction, snowfall, etc. it only handles a few tiles at a time, but it will come back to the same tile after 256 ticks (about 3.5 game days)
i have done something like that here for trains (just not affecting the pathfinder): http://www.tt-forums.net/viewtopic.php?f=33&t=47095
i have done something like that here for trains (just not affecting the pathfinder): http://www.tt-forums.net/viewtopic.php?f=33&t=47095
Who is online
Users browsing this forum: Ahrefs [Bot] and 54 guests