Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

YAPF and Road Depots #6410

Closed
DorpsGek opened this issue Jan 7, 2016 · 3 comments
Closed

YAPF and Road Depots #6410

DorpsGek opened this issue Jan 7, 2016 · 3 comments
Labels
flyspray This issue is imported from FlySpray (https://bugs.openttd.org/)

Comments

@DorpsGek
Copy link
Member

DorpsGek commented Jan 7, 2016

juanjo opened the ticket and wrote:

See topic: http://www.tt-forums.net/viewtopic.php?f=31&t=73100

It seems that this line in yapf_road.cpp:
if (max_distance > 0 && n->m_cost > max_distance * YAPF_TILE_LENGTH) return false;
causes the problem.

m_cost -> cost of the best path (penalty length, not tile length)
max_distance -> usually 2000. It is also penalty length (2000 with penalty is about 20 tiles)
YAPF_TILE_LENGTH = 100

With r27488, if a vehicle needs servicing and it finds a depot at a distance less than 2000 tiles, it will go there skipping all other orders. Changing it to:
if (max_distance > 0 && n->m_cost > max_distance) return false;
will do it if the depot is at a distance less than 20 tiles.

This is the easiest way to solve the bug.

Reported version: trunk
Operating system: All


This issue was imported from FlySpray: https://bugs.openttd.org/task/6410
@DorpsGek
Copy link
Member Author

DorpsGek commented Jan 7, 2016

juanjo wrote:

As I was trying to solve it, I came across that:
- YAPF for rail uses max_distance in a more efficient way: it discards paths longer than max_distance while searching a path. Road and ship do not do it.
For some reason it hasn't been done. Probably, something about efficiency. I could try extending it to road and ship depots if other developers consider it appropriate. If that could be done, I could try with ships finding depots in a better way (#5713 - Boats sent to impossible depots).

- FindDepot in YAPF calculates the cost of the best path, but doesn't return it. If a depot is found, it returns a cost of max_distance/2.
I think that returning a FindDepotData object (tile, cost and reversed) makes the code easier to read. Maybe returning a bool is faster, but I don't know if that is really necessary. The attached patch is for changing this, that could also be changed for YAPF rail.

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/6410#comment14108

@DorpsGek
Copy link
Member Author

frosch wrote:

Yes, adding "discarding long paths" to road- and ship pathfinder would be nice.
I referenced your comment in #5713.


This comment was imported from FlySpray: https://bugs.openttd.org/task/6410#comment14199

@DorpsGek
Copy link
Member Author

frosch closed the ticket.

Reason for closing: Fixed

in r27586. Thanks for the patch!


This comment was imported from FlySpray: https://bugs.openttd.org/task/6410

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flyspray This issue is imported from FlySpray (https://bugs.openttd.org/)
Projects
None yet
Development

No branches or pull requests

1 participant