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

CPU draws power even when game is paused? #526

Closed
Dunbaratu opened this issue Jan 28, 2015 · 4 comments · Fixed by #721
Closed

CPU draws power even when game is paused? #526

Dunbaratu opened this issue Jan 28, 2015 · 4 comments · Fixed by #721
Assignees
Labels
bug Weird outcome is probably not what the mod programmer expected.

Comments

@Dunbaratu
Copy link
Member

Two users have both reported in the forums that the kOS CPU part draws power even when the KSP game itself is paused. Pause the game with the CX-4181 turned on, go away for a few hours leaving your gaming PC turned on, and come back, and your ship is out of power even though no time has passed on the game clock.

I suspect that Timewarp.fixedDeltaTime is the wrong way to be calculating this, as well, because Updates() happen more (or less if your computer sucks) often than fixed updates. Draining power by one fixed Delta Time step each Update time means people who's frame rate is 2x physics rate are getting charged for electricity doubly, I think.

So there's really two problems at once, if this is happening:

1 - If Update() gets called when the game is paused, then we have to catch that condition instead of running IPU number of instructions each Update while paused. Pausing the gameworld should pause the kOS script.
2 - If running Update() is causing power to drain even when the game is paused (and presumably time isn't passing on the world clock) then that's evidence that we shouldn't be consuming power as if Timewarp.fixedDeltaTime was passing every Update, because clearly it's not. Even without the pausing problem, there's still the framerate problem and something else should be used to calculate power usage.

Power save mode??
Perhaps this is a good opportunity to consider implementing some sort of clock speed power save idea while we're at it. Make the unit drain less power when IPU is lower. We could do this perhaps very easily by doing the electrical charge as a micropayment. Find out how much drain typically happens within one Update(), divide that by 150 to get a tiny drain amount, and then charge that tiny amount just before executing each instruction. This would depend on the floating point numbers being able to operate lots of times on values that small without too much cumulative error, of course.

If this was implemented, then faster computers would take more energy drain, and putting the computer into sleep mode by intentionally reducing IPU to something like 1 (the current gui widget clamps to no lower than 50 but that could be changed), makes it drain less power. With that you could put your script into a mode where pretty much ALL it does is wait to wake itself up in a tiny simple loop, with all Whens, Ons, locks, etc turned off. an IPU of 1 would be enough to run in this mode and then it could put the IPU back to 150 when it wakes up.

@erendrake erendrake added the bug Weird outcome is probably not what the mod programmer expected. label Feb 21, 2015
@Dunbaratu Dunbaratu added this to the v0.17.0 Punchlist milestone Apr 2, 2015
@Dunbaratu
Copy link
Member Author

added to 0.17 because I expect it will automatically get fixed when we use fixedupdate.

@abenkovskii
Copy link
Contributor

@Dunbaratu @erendrake This bug is back in kos 0.17.2 somehow.

@erendrake
Copy link
Member

@abenkovskii are you serious :P

@hvacengi
Copy link
Member

I think I found the cause. ProcessElectricity never got moved. I'll test it later tonight.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Weird outcome is probably not what the mod programmer expected.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants