Skip to content

Added overflow algorithm for repair stations#4544

Open
Monsterovich wants to merge 1 commit intoWarzone2100:masterfrom
Monsterovich:feat-repair
Open

Added overflow algorithm for repair stations#4544
Monsterovich wants to merge 1 commit intoWarzone2100:masterfrom
Monsterovich:feat-repair

Conversation

@Monsterovich
Copy link
Copy Markdown
Contributor

pic

The rebased version of #3686

@vaut
Copy link
Copy Markdown
Contributor

vaut commented Sep 7, 2025

Firstly, I couldn't notice any difference in behavior after applying the patch. forgot to git patch :(

Secondly, I'm against changing the behavior of retreating for repairs.
On low oil, the distant repair shop can be on the other flank. The unit that goes there will die.
Retreating to the base is also bad. The travel time from the base to the front is long.

And thirdly, I don't see a problem in the fact that you need to build repair shops in the right place in the right order for effective play. After improvements from @gantsevdenis
#1829 (comment)
Retreating for repairs has become adequate.

@Monsterovich
Copy link
Copy Markdown
Contributor Author

Monsterovich commented Sep 7, 2025

Firstly, I couldn't notice any difference in behavior after applying the patch.

It literally works in the screenshot.

Secondly, I'm against changing the behavior of retreating for repairs.

The behavior that we have now is completely flawed. Because the algorithm searches for the nearest station and doesn't consider its capacity. As a result, there is an unending crowd of units at one station, while other stations remain unutilized. Therefore, people build stations near and parallel to the flow of units.

See: #3686 (comment)

On low oil, the distant repair shop can be on the other flank. The unit that goes there will die.

This situation is unlikely on low oil because the flow of units is initially small. Also show me this edge case, I think it can also be circumvented if the stations distribute the units correctly. We could add a switch in the UI that would disable overflow checking for individual stations.

Retreating to the base is also bad. The travel time from the base to the front is long.

On the contrary, retreating to base in extreme cases preserves the army, because there are cases when one station cannot handle so many repairs, and the army crowds around this one station without being able to move and is often killed by the enemy as a result.

And thirdly, I don't see a problem in the fact that you need to build repair shops in the right place in the right order for effective play.

To reiterate, the only approach people use is to build repair stations nearby and preferably parallel to the flow. Other options will lead to crowding issues and manual distribution between stations.

@vaut
Copy link
Copy Markdown
Contributor

vaut commented Sep 7, 2025

Why is this option for building repair shops bad?

At low, experienced players will not build 5 repair shops in one place, usually 1-2.

I do not want hidden mechanics to decide for me how to save my units. If a repair shop is overloaded, an army accumulates next to it. This is normal. I will see it and take action. But the situation that suddenly units, instead of waiting for their turn for repair, go to the other side of the map does not suit me at all.

@vaut
Copy link
Copy Markdown
Contributor

vaut commented Sep 7, 2025

If this behavior is good, then I can't imagine what bad behavior must look like.
https://youtu.be/eX0HdiXKldY

@Monsterovich
Copy link
Copy Markdown
Contributor Author

experienced players will not build 5 repair shops in one place, usually 1-2

When there is a large flow of units, I build five stations side by side, and everyone does the same. For obvious reasons.

Everything else works worse, you have to manually redirect units to free stations or to the base, etc.

If a repair shop is overloaded, an army accumulates next to it. This is normal.

This sucks and it's not normal. I have already explained why. Stations cannot be built far apart from each other and be as effective as five stations built close together.

@Monsterovich
Copy link
Copy Markdown
Contributor Author

Monsterovich commented Sep 7, 2025

If this behavior is good, then I can't imagine what bad behavior must look like. https://youtu.be/eX0HdiXKldY

This is a hypothetical situation. In real games, people either build more stations, or build them closer to the base, or we can make an overflow switch, as I've suggested.

BTW, without this patch, you will get a crowd of units at that one station. Both cases are bad because there is simply not enough repair capacity. No one would do that in a real game.

@vaut
Copy link
Copy Markdown
Contributor

vaut commented Sep 7, 2025

If this behavior is good, then I can't imagine what bad behavior must look like. https://youtu.be/eX0HdiXKldY

This is a hypothetical situation. In real games, people either build more stations, or build them closer to the base, or we can make an overflow switch, as I've suggested.

BTW, without this patch, you will get a crowd of units at that one station. Both cases are bad because there is simply not enough repair capacity. No one would do that in a real game.

Yes, this is a bad situation that your patch makes terrible.
But it is very real: you are trying to overcome the overcrowding of repair shops.
And in what real situations are your changes better? At the same time, the benefit should cover the problems from possible problems.

@Monsterovich
Copy link
Copy Markdown
Contributor Author

Monsterovich commented Sep 7, 2025

If this behavior is good, then I can't imagine what bad behavior must look like. https://youtu.be/eX0HdiXKldY

This is a hypothetical situation. In real games, people either build more stations, or build them closer to the base, or we can make an overflow switch, as I've suggested.
BTW, without this patch, you will get a crowd of units at that one station. Both cases are bad because there is simply not enough repair capacity. No one would do that in a real game.

Yes, this is a bad situation that your patch makes terrible. But it is very real: you are trying to overcome the overcrowding of repair shops. And in what real situations are your changes better? At the same time, the benefit should cover the problems from possible problems.

You're either a troll or you don't know how to play. Why are you making up unrealistic situations? You know perfectly well that all players build repair stations at or near their bases, also for obvious reasons.

We can make an overflow switch for repair stations. It would even work for your hypothetical cases (that you have invented yourself).

@vaut
Copy link
Copy Markdown
Contributor

vaut commented Sep 7, 2025

I still want to see a detailed answer with an example of when your patch makes the game more enjoyable.

repair stations at or near their bases, also for obvious reasons.
Not like in your screenshot, repair on different flanks.

After Denis' patches, units retreat to a random repair shop located in the group.
Here is an example of how units are distributed among 3 rather distant repair shops. Where is the problem here?
https://youtu.be/nyJyaycHjnQ

@Monsterovich
Copy link
Copy Markdown
Contributor Author

Monsterovich commented Sep 7, 2025

I still want to see a detailed answer with an example of when your patch makes the game more enjoyable.

That's how it works now.

pic

Okay, I might not build them like that in a real game.

Let's spread them out across the base. The units will still go strictly to one nearest facility regardless of how crowded it is. I can even take a regular low oil map with a similar structure, except that the unit flow isn't as high there.

pic2

You will have to use the mouse to move units to other facilities because the algorithm doesn't care about crowding.

Guess how people make their repair facilities?

1 2 3 4

+2 behind those three as a fallback (I do that sometimes too, but it's risky because it can create crowding. My patch would help with this.)

4.1 5 6

10 out of 10 players did this because of the weird distribution algorithm (well, one player didn't build repair facilities, but used cyborgs at the base).

I picked the last demo I played.

@ligtsanger
Copy link
Copy Markdown

skill issues must not be handled with changing of the entire game. I would suggest you to improve yourself at the game first, because right now your suggestion is based on your personal experience or expierence of players of same level and it looks like "i want a button to win me the game". People place their repair facilities this way because it is right way, like using anti-personnel weapon to kill cyborgs. It's obviously that if you do some things wrong they don't work out and you lose, but it is your personal problem, not a proper reason to change the game.

Imo this PR must go thru approval process because it affects mp balance and i'm sure many of players will not be pleased to know that their units gonna go to command center instead of waiting near repair facilities.

@Monsterovich
Copy link
Copy Markdown
Contributor Author

Monsterovich commented Sep 7, 2025

skill issues must not be handled with changing of the entire game. I would suggest you to improve yourself at the game first, because right now your suggestion is based on your personal experience or expierence of players of same level and it looks like "i want a button to win me the game"

Following this logic, we should remove automatic retreat for repair. This is for noobs with skill issues. Players should manually select units with low HP and click "retreat". /sarcasm

Remember the patch that improved transporters? That's not necessary either; people should click on each transporter. /sarcasm

People place their repair facilities this way because it is right way,

Because now it's the best option, which has the fewest problems due to the algorithm.

Imo this PR must go thru approval process because it affects mp balance

It doesn't affect the balance in any way. Retreat is an automated part of the interface, the same as assigning groups to units in factories — there is no difference. This won't change how people built stations before; on the contrary, it will open up other possibilities that are currently unavailable due to an imperfect distribution algorithm.

@ligtsanger
Copy link
Copy Markdown

It doesn't affect the balance in any way.

Atm units don't retreat in base if there is no free repair facility, so PR definitely affects unit behaviour and the balance as the result.

This sucks and it's not normal. I have already explained why. Stations cannot be built far apart from each other and be as effective as five stations built close together.

five facilities together work better because 2+ facilities can repair one unit pure math.

On the contrary, retreating to base in extreme cases preserves the army, because there are cases when one station cannot handle so many repairs, and the army crowds around this one station without being able to move and is often killed by the enemy as a result.

Preservation of damaged army will not help you, no difference between losing this units near repair facilities or in base.

You're either a troll or you don't know how to play. Why are you making up unrealistic situations? You know perfectly well that all players build repair stations at or near their bases, also for obvious reasons.

people build repairs near bases if they are planning to sit on base. Usually in other situations people build repairs near frontline, leaving some space to retreat. Again, pls don't judge the game by your personal experience which you are lacking.

@aco4
Copy link
Copy Markdown
Contributor

aco4 commented Sep 7, 2025

How about adding a distance check, so the unit will not overflow to the next repair facility if it is too far away

@Monsterovich
Copy link
Copy Markdown
Contributor Author

Atm units don't retreat in base if there is no free repair facility, so PR definitely affects unit behaviour and the balance as the result.

I have already explained that the problem of crowds at stations is much worse than all other cases. We can make a switch between different behaviors. But this does not affect the balance in any way. In theory, I can even make this patch behave in such a way that it will only work on client-side.

five facilities together work better because 2+ facilities can repair one unit pure math.

It doesn't matter whether they repair one unit or a few individually; that's not the point at all.

Preservation of damaged army will not help you, no difference between losing this units near repair facilities or in base.

Well, that's ridiculous. In any RTS, saving every unit is important.

@Monsterovich
Copy link
Copy Markdown
Contributor Author

How about adding a distance check, so the unit will not overflow to the next repair facility if it is too far away

It can be done. But how many tiles should this distance be?

@vaut
Copy link
Copy Markdown
Contributor

vaut commented Sep 7, 2025

How about adding a distance check, so the unit will not overflow to the next repair facility if it is too far away

Units are already being redistributed to nearby repair shops. Watch my second video or gifs from Denis' patch.

@past-due
Copy link
Copy Markdown
Member

past-due commented Sep 7, 2025

How about adding a distance check, so the unit will not overflow to the next repair facility if it is too far away

At that point, we might as well just slightly increase MAGIC_SUITABLE_REPAIR_AREA, which was my suggestion from the prior PR (and improves this situation while not triggering the same concerns mentioned by others above).

There are several issues with the approach in this PR:

  • As mentioned above (and in the prior PR), this is a potentially undesirable behavior change in several respects, especially with how all of a sudden some units will just get directed all the way to HQ / RTB
  • By the time units could reach a destination repair facility, it may have room - but would have been eliminated from contention due to the earlier moment when checks were made
  • Iterating over droids is something we’re trying to avoid adding more of, as it adds friction / performance hotspots when increasing unit limits - this adds a loop over all player droids for (potentially) every single repair facility

@Monsterovich
Copy link
Copy Markdown
Contributor Author

Monsterovich commented Sep 7, 2025

At that point, we might as well just slightly increase MAGIC_SUITABLE_REPAIR_AREA, which was my suggestion from the prior PR (and improves this situation while not triggering the same concerns mentioned by others above).

Hm. This value needs to be increased to ~24-32 tiles to cover the case on my screenshot.

Oh, and it has its own drawbacks too, because units will be randomly distributed and therefore may be distributed inefficiently. In my patch, they go to the nearest station if it is not crowded.

We can make the overflow function optional for each repair station (switch button or such).

@Raptor959
Copy link
Copy Markdown

Raptor959 commented Oct 3, 2025

As someone who actually plays low-oil vanilla map games this is a welcome change, Especially if it applies to repair units and not just repair facilities. The "potentially undesirable behavior" that people are worrying about basically already happens with the current algorithm in such games, Except it's worse because it just happens due to map layout and unit positioning instead of from units maximizing repair station usage.

The idea that you're "supposed" to build repair facilities "-in the right place in the right order for effective play" is an NTWbrain argument not something backed up by a gameplay system that distinguishes good strategy versus bad strategy, Rather it is an adaptation to an unseen, unintuitive, and therefor frustrating algorithm. It also doesn't explain how this change would enable effective usage of facilities facilities that are not "-in the right place in the right order" or how players who use the current "right" place/order will actually be worse off.

@aubergineagain
Copy link
Copy Markdown
Contributor

aubergineagain commented Nov 17, 2025

Could the distance a droid is willing to travel for repair be based on their speed? So faster droids will be willing to travel longer distances.

There could be buttons on repair stations/droids to set what damage level they prefer (red, yellow, or any). This way player can set stations nearest to front line as red, and stations further back as yellow, or vice versa. This way the player gets some control over how it works, you can sort of pull different damage levels to different areas.

Also buttons on HQ/CC that toggles whether it's allowed destination for broken droids and if so what damage level. I might want red bar droids to go back to base but not yellow, resulting in yellow staying in the fight until either a repair station has capacity or they reach red bar and go running back to base.

Also, instead of droids heading directly for a given repair station, have them head to a nearby spot so there's some room for droids to move around. Or have a red map triangle that acts as a waiting area for the station, and after they get repaired they head to the green triangle. While at the waiting area, if another station nearby gets capacity they can go there instead of the one they're waiting at.

And maybe stations could prioritize fastest to heal first in order to clear the backlog quicker and free up space for more needy droids.

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.

7 participants