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

Fix #5713: Use pathfinder to find closest ship depot #6928

Closed

Conversation

Projects
None yet
5 participants
@SamuXarick
Copy link
Contributor

commented Oct 1, 2018

When ships are asked to find the closest depot, the depot that is provided is not always reachable. This patch provides the closest reachable ship depot, by utilizing the pathfinder (Original, NPF or Yapf) first. Only if it fails, it would then be provided by the original method, distance manhattan based.

https://www.tt-forums.net/viewtopic.php?f=33&t=76137

@nielsmh
Copy link
Contributor

left a comment

I don't like this approach at all. It's far too intrusive and adds far too many special cases to the pathfinding code, which is already very complex. Start over with something simpler that doesn't need to change code in all the pathfinders.

@nielsmh

This comment has been minimized.

Copy link
Contributor

commented Nov 1, 2018

An idea for an alternate approach could be to insert the logic in ShipController instead. If after ChooseShipTrack the VF_PATHFINDER_LOST flag is set, and the current order is go to depot (and it's not a scheduled order) then select a different depot and try again. It's probably necessary to keep a list of depots already tried (and failed), but it can just be local to the ship controller function.

Of course that won't handle the case of OPF, since that never signals no path found. I would suggest not doing anything about that for now, but maybe make a separate change that keeps track of how far a ship has sailed since it last completed an order, and compare that to the expected distance, and send a warning to the player if the ship appears to be taking too long.

@nielsmh

This comment has been minimized.

Copy link
Contributor

commented Nov 2, 2018

I tried implementing the approach I outlined above, it's probably not complete like this, but it's significantly shorter and touches much less code: nielsmh@fd90477

@TrueBrain

This comment has been minimized.

Copy link
Member

commented Jan 5, 2019

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!

@SamuXarick SamuXarick force-pushed the SamuXarick:find-closest-reachable-ship-depot branch from e556519 to b8b7878 Jan 10, 2019

@SamuXarick

This comment has been minimized.

Copy link
Contributor Author

commented Jan 10, 2019

@nielsmh
I just experimented your approach and it causes stalls during gameplay when there's too many unreachable depots nearby. It calls the pathfinder for everyone of them.

@J0anJosep has already implemented part of what I had in mind for npf, which got into master, and some of the complexity that was on npf.cpp is gone. Unless you mean the other changes...

@SamuXarick SamuXarick force-pushed the SamuXarick:find-closest-reachable-ship-depot branch from b8b7878 to e4a026e Jan 10, 2019

@nielsmh
Copy link
Contributor

left a comment

Still think this looks like too much complexity to attempt to improve a few corner cases.

Show resolved Hide resolved src/pathfinder/opf/opf_ship.cpp Outdated
Show resolved Hide resolved src/pathfinder/opf/opf_ship.cpp Outdated
Show resolved Hide resolved src/pathfinder/opf/opf_ship.cpp Outdated
Show resolved Hide resolved src/pathfinder/opf/opf_ship.cpp Outdated
Show resolved Hide resolved src/pathfinder/opf/opf_ship.h Outdated
Show resolved Hide resolved src/ship_cmd.cpp Outdated
Show resolved Hide resolved src/ship_cmd.cpp Outdated
Show resolved Hide resolved src/pathfinder/opf/opf_ship.cpp Outdated
Show resolved Hide resolved src/pathfinder/opf/opf_ship.cpp Outdated
Show resolved Hide resolved src/pathfinder/opf/opf_ship.cpp Outdated

@SamuXarick SamuXarick force-pushed the SamuXarick:find-closest-reachable-ship-depot branch 3 times, most recently from 3060a64 to a5c5df2 Jan 12, 2019

@SamuXarick

This comment has been minimized.

Copy link
Contributor Author

commented Jan 12, 2019

NoNoCAB v5 (O) 1.7.2.zip
Savegame with 5000 ships for testing

Show resolved Hide resolved src/pathfinder/npf/npf.cpp
Show resolved Hide resolved src/pathfinder/opf/opf_ship.cpp Outdated
Show resolved Hide resolved src/ship_cmd.cpp Outdated

@SamuXarick SamuXarick force-pushed the SamuXarick:find-closest-reachable-ship-depot branch from a5c5df2 to 74e3985 Jan 13, 2019

@SamuXarick

This comment has been minimized.

Copy link
Contributor Author

commented Jan 16, 2019

@SamuXarick SamuXarick force-pushed the SamuXarick:find-closest-reachable-ship-depot branch from 4ba1fe3 to 7a9d5c1 Jan 17, 2019

Code issues resolved

@LordAro
Copy link
Member

left a comment

I'm with @nielsmh on this - this is far too much code to fix this very minor issue. Perhaps @nielsmh's method could be limited to try the first N (where N is small) number of depots before it reverts to the old Manhattan method?

Also there's currently conflicts

SamuXarick added some commits Oct 1, 2018

Fix #5713: Use pathfinder to find closest ship depot
When ships are asked to find the closest depot, the depot that is provided is not always reachable. This patch provides the closest reachable ship depot, by utilizing the pathfinder (Original, NPF or Yapf) first. Only if it fails, it would then be provided by the original method, distance manhattan based.

@SamuXarick SamuXarick force-pushed the SamuXarick:find-closest-reachable-ship-depot branch from 7a9d5c1 to 9ad74e8 Jan 20, 2019

@SamuXarick

This comment has been minimized.

Copy link
Contributor Author

commented Jan 20, 2019

Just resolved conflicts

@andythenorth

This comment has been minimized.

Copy link
Contributor

commented Jan 24, 2019

This one appears to be stuck, and reviewers are finding it difficult to providing constructive reviews. Also it appears difficult to be confident that the solutions proposed are correct. On this basis I am closing this one. Thanks for contributing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.