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

Add #6410: [YAPF] Use a max penalty for finding the nearest road vehicle depot #6929

Conversation

SamuXarick
Copy link
Contributor

@SamuXarick SamuXarick commented Oct 1, 2018

Implemented a maximum path cost penalty when searching for the closest road vehicle depot for YAPF
#6410

Implemented a maximum path cost penalty when searching for the closest road vehicle depot for YAPF
@SamuXarick SamuXarick changed the title Add: [YAPF] Use a max penalty for finding the nearest road vehicle depot Add #6410: [YAPF] Use a max penalty for finding the nearest road vehicle depot Oct 2, 2018
@PeterN
Copy link
Member

PeterN commented Oct 2, 2018

What does this solve?

@SamuXarick
Copy link
Contributor Author

SamuXarick commented Oct 2, 2018

Apparently it changes nothing, but makes the pathfinder quit earlier if it goes past the max_penalty.

Seems that the penalty is only used for automatic servicing. Manual sending to depot still uses unlimited penalty.

@J0anJosep
Copy link
Contributor

@SamuXarick Yes, it leaves earlier and the max_distance penalty is used. For consistency, either max_distance should be used or removed from the code. I forgot to add a patch for it, but I wrote them two years ago (YAPF and NPF):
J0anJosep@d6a311b
J0anJosep@3680d95
Sorry for forgetting about it. Double work done here.

Anyway, I don't see why a change in max_distance is needed.

@SamuXarick
Copy link
Contributor Author

SamuXarick commented Oct 2, 2018

Because

/**
* Used when user sends road vehicle to the nearest depot or if road vehicle needs servicing using YAPF.
* @param v vehicle that needs to go to some depot
* @param max_penalty max distance (in pathfinder penalty) from the current vehicle position
* (used also as optimization - the pathfinder can stop path finding if max_penalty
* was reached and no depot was seen)
* @return the data about the depot
*/
FindDepotData YapfRoadVehicleFindNearestDepot(const RoadVehicle *v, int max_penalty);

Oh, I did that for NPF too, included it in my other patch request #6928

e556519#diff-fe68d910d6c0b0a8d81eb65e88e60fb1

@J0anJosep
Copy link
Contributor

Because

OpenTTD/src/pathfinder/yapf/yapf.h

Line 70 in 25a060b
FindDepotData YapfRoadVehicleFindNearestDepot(const RoadVehicle *v, int max_penalty);

Oh, I did that for NPF too, included it in my other patch request #6928

e556519#diff-fe68d910d6c0b0a8d81eb65e88e60fb1

In the file you referenced, both max_distance and max_penalty are used and their meaning is the same. It is explained in the comments. If it is an inconsistency, it shouldn't be dealt here but in a separate commit.

@TrueBrain
Copy link
Member

We recently switched from Jenkins as CI to Azure Pipelines as CI. This means you need to rebase before this Pull Request will pass its checks. Sorry for the troubles!

@andythenorth
Copy link
Contributor

Same issue is addressed by #7009, which is merged.

@SamuXarick SamuXarick deleted the max-penalty-for-yapf-find-closest-road-vehicle-depot- branch January 14, 2019 19:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants