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 of diode's strange behavior #10454

Merged
merged 1 commit into from
Feb 4, 2025
Merged

fix of diode's strange behavior #10454

merged 1 commit into from
Feb 4, 2025

Conversation

Maxiron794
Copy link
Contributor

If your pull request is not translation or serverlist-related, read the list of requirements below and check each box:

  • I have read the contribution guidelines.
  • I have ensured that my code compiles, if applicable.
  • I have ensured that any new features in this PR function correctly in-game, if applicable.

While experimenting with the power diode, I found inconsistencies in its behavior.

Its purpose is to transfer power when the back power graph has a higher percentage of stored energy than the front power graph, but it doesn't actually intend to balance them that way.

For example, a fully charged large battery will transfer 50000 * (1 - 0) / 2 = 25000 energy (clamped to 4000) to a small battery. However, intuitively it should be around 3700.

This code fixes the issue. I also believe that there is no longer any need for the clamp or for dividing by 2, but it remains unchanged.

Before:
image
image
image

After:
image
image
image

@LieutenantH
Copy link

I think that the battery diode works on total stored power, not percent.
This means the behavior is actually correct.

"Moves battery power in one direction, but only if the other side has less power stored."

@Maxiron794
Copy link
Contributor Author

I think that the battery diode works on total stored power, not percent. This means the behavior is actually correct.

"Moves battery power in one direction, but only if the other side has less power stored."

Okay, that's possible, but if batteries are switched:

image
image
image

Shouldn't it be 2k and 2k?

@LieutenantH
Copy link

Did the small battery get placed first?

And yeah, it definitely is weird. I think it might not activate instantly to stop it (or something).

You could be right about it being broken.
Idk.

@Anuken Anuken merged commit aa8e3b4 into Anuken:master Feb 4, 2025
2 checks passed
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.

3 participants