Replace thermomachine dynamic per-tick power with flat target-based draw#617
Replace thermomachine dynamic per-tick power with flat target-based draw#617
Conversation
…ased power draw Co-authored-by: Ossa88 <8151625+Ossa88@users.noreply.github.com>
|
I kinda wanted to see how this system functioned as it was kinda interesting. None the less CoPilot basically undid my last PR, which only worked when a single thermo machine was on the network, and totally failed the second multiple thermo machines on the same network. For whatever reason I never thought to think of testing two machines both fighting to heat up, and cool down, the same pipe network. Nor did I realize that each instance of the machine registering how much power it was consuming... all shared the same registration. |
…sed on target temperature changes
|
Uhh, Is this to be TM'd? I don't like AI PRs... What percentage of this is human and what was Ossa? |
Yes it can be TMed. All copilot did, was deleted all of the things I personally had merged in a previous PR, and reset it back to shiptests broken version, then broke off the part of the code that ran the calculations into a proc and just set the power use to be flat rate. After which I realized what was actually going wrong and upgraded the new power calculation proc back to what it was supposed to be. |
|
Ah, AI doing it wrong is (part of) why I don't like it. Alright, TMing it now. |
I was at work, I was bored. I wanted to fix the problem as I had a basic idea of what was wrong. I am unable to actually do anything from work and decided to just peak around in Co-Pilot. You can read the entire discussion history for it. I wanted to see what the process was like, and be transparent. All this kind thing will push people who do use AI for code or debugging or error finding into the shadows. |
|
On this note, I do have a second version that reduces the downstream code drift by like 90%. It just moves the new proc back into the main if statement and forces the APC cost refreshing to actually happen. The problem is the on/off state changing and how it was adding to/taking away from the APC power draw count. I have not fully tested the second version... because to really get the bug to work I would have to induce lag, and thats rather hard when VSC is monitoring the tickrate and the second lag happens it pauses the stimulation. |
Multiple thermomachines on the same gas network race on the shared area power total: each tick they remove their old registration and add a new one, causing compounding interference when two machines process in the same tick.
Changes
recalculate_power()proc: computesactive_power_usagefrom the target temperature offset from the current gas temp, registered once via standardset_active_power()/set_idle_power():last_registered_powervariable and the entire per-tickaddStaticPower/removeStaticPowerdance fromprocess_atmos()recalculate_power()called on all state-changing paths:RefreshParts(),ui_act()(power toggle + target change),CtrlClick(),freezer/on/Initialize(),coldroom/Initialize(),freezer/AltClick(),heater/AltClick()update_parents()inprocess_atmos()— only fires when temperature actually changed by >1K, matching theheat_exchangerpatterninvestigate_loginCtrlClick()that was referencing the wrongusrvariableOriginal prompt
This pull request was created from Copilot chat.
🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.