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

Change: Cap docking tile occupancy penalty to a max of one ship #9514

Closed
wants to merge 1 commit into from

Conversation

SamuXarick
Copy link
Contributor

@SamuXarick SamuXarick commented Aug 27, 2021

Motivation / Problem

Main problem is that there is no cap to 'docking tile occupancy penalty' - if there are 50 ships on the docking tile, the cost is ~50 times higher.

The higher the penalty/cost, the more likely the chances for the pathfinder to report ship is lost for other ships that are part of this route. If there's lots of water near the docking tile which is also the pf's destination, it will start looking for those cheaper nodes first, resulting in more search nodes being needed to find a path.

It really seems like a waste to search nodes around the destination. It's understandable that the penalty is being used to help send the ships to other docking tiles of the same multi-dock station, but... oh well.

Also refer to #8001

Description

This PR limits the penalty cost to a max of one ship in the docking tile. There's the cost of the tile being a docking tile which is 300 in YAPF, and then there's the cost of it being occupied by ships, which is also 300 in YAPF. So, at max, it's an added 600 cost now, instead of a cost that was dependent on the number of ships in the tile.

Limitations

This PR may help mitigate 'ship is lost' messages which are triggered when the max number of search nodes is reached by the pf, but in all honesty, it feels insufficient still to what the game used to be before this penalty ever existed.

Checklist for review

Some things are not automated, and forgotten often. This list is a reminder for the reviewers.

  • The bug fix is important enough to be backported? (label: 'backport requested')
  • This PR touches english.txt or translations? Check the guidelines
  • This PR affects the save game format? (label 'savegame upgrade')
  • This PR affects the GS/AI API? (label 'needs review: Script API')
    • ai_changelog.hpp, gs_changelog.hpp need updating.
    • The compatibility wrappers (compat_*.nut) need updating.
  • This PR affects the NewGRF API? (label 'needs review: NewGRF')

@TrueBrain
Copy link
Member

TrueBrain commented Aug 28, 2021

I am not sure what this PR fixes, and I think this is a bad change. It basically "soft" reverts the intention of the code, without any real argumentation why that would be better.

I am guessing this is an attempt to fix #8001, but this is not mentioned. So I am collecting context here .. I might misunderstand all of this :P

The higher the penalty/cost, the more likely the chances for the pathfinder to report ship is lost for other ships that are part of this route. If there's lots of water near the docking tile which is also the pf's destination, it will start looking for those cheaper nodes first, resulting in more search nodes being needed to find a path.

Yes, that is exactly what Path Finders do. This is not an issue, this is their purpose in life.

It really seems like a waste to search nodes around the destination. It's understandable that the penalty is being used to help send the ships to other docking tiles of the same multi-dock station, but... oh well.

You contradict yourself. It is not a waste, it makes multi-dock stations useful (as otherwise they are not useful, what the original change set out to fix). That you do not like it, doesn't make it "a waste". Or if there is an other argumentation here, I do not see it.

This PR limits the penalty cost to a max of one ship in the docking tile. There's the cost of the tile being a docking tile which is 300 in YAPF, and then there's the cost of it being occupied by ships, which is also 300 in YAPF. So, at max, it's an added 600 cost now, instead of a cost that was dependent on the number of ships in the tile.

You explain what it does, which the code tells me too. But this is not a motivation. Let me put it in different words:

  • "Please explain if you want to go left or right on this street"
  • "I am going left, as left is the direction I am going"

Motivation explains why you are going left. Not the fact that you do.

I have no clue why you picked "1" over "2" or any other value for example. Or why you think capping it is the way to go.

As counter suggestion, I would think that some diminishing return value would be better. I can understand that 300 + N * 300 might be a bit much. But there is a difference between 1 and 2 ships at a dock. So maybe the second ship shouldn't be 300, but neither should it be 0.

@TrueBrain TrueBrain added the candidate: probably not This Pull Request will most likely be closed soon label Aug 29, 2021
@TrueBrain
Copy link
Member

Right, there has been some talk on IRC about this, lets sync up the information:

  • The author of this PR didn't consider multi-docks.
  • This PR seems to dismiss multi-docks all together, and soft-reverts it back to before balancing between docks was introduced. This basically means this PR is a regression.
  • This PR seems to scratch an itch ("it is wasting CPU"), and not really fixes anything. It is properly called "Change", but what it actually changes is rather unclear.
  • This PR does not address Ship finds path but reports it is lost #8001. Plenty of other scenarios can be created where a ship is still considered lost.

Additionally, the strong suggestion made on IRC is that the "ship is lost" part is in a different part of the code. Looking back to what I wrote yesterday, it is also a bit hard to believe that adding a penalty of a single tile for each ship docked makes a difference in whether a ship is lost or not. The intention is exactly that you give the pathfinder more and more room to find other docking tiles.

In conclusion I think it is fair to say this PR is not reaching its goal, and as such I am going to close it up now.

Additional information and analysis is needed and very welcome.
To not pollute one solution with the other, please create a new PR for this; also please in such PR try to explain what cases you considered (and what you dismisses), and what you think it is actually fixing. That would greatly speed up the review process.

Lastly, I do appreciate the attempt to address these issues, and at least this PR sparked a conversation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
candidate: probably not This Pull Request will most likely be closed soon
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants