Calculate inserter arm positions only when the GPU or a mod wants them
Moderator: ickputzdirwech
Calculate inserter arm positions only when the GPU or a mod wants them
Top lesson from the UPS Wars threads hasn't changed: inserter swings almost completely dominate production cost. I suspect it's because the engine updates the inserter arm position every tick, but why? There's no collision checks, arm position mid-swing is there for us humans to look at, right? So how about storing just the arrival tick and target point, plus swing and extension rates for each inserter swing?
Re: Calculate inserter arm positions only when the GPU or a mod wants them
what if power is shut down during the swing ?
Koub - Please consider English is not my native language.
Re: Calculate inserter arm positions only when the GPU or a mod wants them
Power-out's already an exceptional condition, right? Worst case, in a brownout you have to fall back to per-tick inserter updates, I'd think it's just whenever the power supply changes that you have to recalculate the swing.
Re: Calculate inserter arm positions only when the GPU or a mod wants them
That 92% touch-count reduction kept my monkey chattering until it came up with this:
Swinging inserters go on a head-tail queue, simplest might be one for every connected-power-grids and delivered-joules-required combination. The list anchor has a what's-on-the-list summary and a count of how many joules have ever been delivered to every item on that list; queuing an inserter swing is just updating the summary and four pointers and power delivery is updating the summary then an unsigned-subtract-and-compare-until-done dequeue loop, no updating the list entries themselves required.
For example: a normal stack inserter swing is 13 ticks, 133kW max 1kW min, 1kW*13/60s is 216⅔J/tick drain, so the inserter needs 133000*13/60-216⅔*13/60=26000 delivered joules to complete its swing. Adding an inserter to the 26000J-swing queue means the list append, incrementing the count of inserters on that queue, adding the inserter's drain, and copying the current delivered-joules total plus 26000 to the target joules in the list entry. Power delivery means subtracting the list drain, dividing by the list count, adding to the delivery total, and dequeuing everything from the front that's been fully supplied, updating the list drain and count accordingly. Account for drain in 60ths of a joule and there's no rounding error; account for delivered and target joules as an unsigned and there's no overflow or resetting.
No-touch-until-done, unless the GPU or a mod needs the current position, then the current swing fraction is 1-(target-delivered)/required.
I've learned, when my monkey won't shut up there's something there. I promise, though, _I_ will. I'll just sign off with "have mercy on me".
Swinging inserters go on a head-tail queue, simplest might be one for every connected-power-grids and delivered-joules-required combination. The list anchor has a what's-on-the-list summary and a count of how many joules have ever been delivered to every item on that list; queuing an inserter swing is just updating the summary and four pointers and power delivery is updating the summary then an unsigned-subtract-and-compare-until-done dequeue loop, no updating the list entries themselves required.
For example: a normal stack inserter swing is 13 ticks, 133kW max 1kW min, 1kW*13/60s is 216⅔J/tick drain, so the inserter needs 133000*13/60-216⅔*13/60=26000 delivered joules to complete its swing. Adding an inserter to the 26000J-swing queue means the list append, incrementing the count of inserters on that queue, adding the inserter's drain, and copying the current delivered-joules total plus 26000 to the target joules in the list entry. Power delivery means subtracting the list drain, dividing by the list count, adding to the delivery total, and dequeuing everything from the front that's been fully supplied, updating the list drain and count accordingly. Account for drain in 60ths of a joule and there's no rounding error; account for delivered and target joules as an unsigned and there's no overflow or resetting.
No-touch-until-done, unless the GPU or a mod needs the current position, then the current swing fraction is 1-(target-delivered)/required.
I've learned, when my monkey won't shut up there's something there. I promise, though, _I_ will. I'll just sign off with "have mercy on me".
Re: Calculate inserter arm positions only when the GPU or a mod wants them
Interesting idea. Worth trying an implementation.
It would be really, really useful, if we have a power sensor, which has a signal, that rises when power is not 100% satisfied. So we would have a chance to turn power off completely (switch) and save much cpu.
It would be really, really useful, if we have a power sensor, which has a signal, that rises when power is not 100% satisfied. So we would have a chance to turn power off completely (switch) and save much cpu.
Cool suggestion: Eatable MOUSE-pointers.
Have you used the Advanced Search today?
Need help, question? FAQ - Wiki - Forum help
I still like small signatures...
Have you used the Advanced Search today?
Need help, question? FAQ - Wiki - Forum help
I still like small signatures...
Re: Calculate inserter arm positions only when the GPU or a mod wants them
Leads to calculate animations only when anybody is watching.
Out of screen entities and smoke could be frozen.
Out of screen entities and smoke could be frozen.
Re: Calculate inserter arm positions only when the GPU or a mod wants them
There's a mod that disables inserter animations. Have you seen that? OP? I wonder if it only disables animations, or completely interferes with their position awareness.
I have mods! I guess!
Link
Link
- eradicator
- Smart Inserter
- Posts: 5206
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: Calculate inserter arm positions only when the GPU or a mod wants them
@quyxkh:
Inserters don't swing in a perfect arc though. They chase items on belts and sometimes wait for the source/target to become unstuck. Does that still work?
Inserters don't swing in a perfect arc though. They chase items on belts and sometimes wait for the source/target to become unstuck. Does that still work?
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Re: Calculate inserter arm positions only when the GPU or a mod wants them
Worst case this only works for container-to-container swings, but I don't think inserters recalculate their target mid-swing, I think if they get to their target and there's nothing there they try again with a newly-calculated target.eradicator wrote: ↑Sat Nov 09, 2019 2:13 pm@quyxkh:
Inserters don't swing in a perfect arc though. They chase items on belts and sometimes wait for the source/target to become unstuck. Does that still work?
-
- Fast Inserter
- Posts: 187
- Joined: Fri Jan 05, 2018 5:18 pm
- Contact:
Re: Calculate inserter arm positions only when the GPU or a mod wants them
This is actually quite easy to do. Have a counter circuit connected to a solar panel and accumulator which is separate from the rest of your power so that it is always fully powered. Then have another counter connected to your regular power source which might possibly have low power. If the power drops, the counter circuit will tick slower than the uninterrupted counter, and you can measure that difference. judos made a daytime detector based on this logic:
viewtopic.php?f=193&t=77046
I can think of two problems with the usage you suggested:
1) You need to prepare some other measurement for when to turn the power back on. Otherwise, your measurement device will flicker on and off. Perhaps you could make it like a circuit breaker, where it stays off until human intervention turns it back on.
2) Does this actually save CPU? My understanding was that unpowered devices can never sleep because they are constantly checking to see if power is back.
Re: Calculate inserter arm positions only when the GPU or a mod wants them
Make inserters work like laser turrets: Either they swing or they don't. They deduct the full power to complete their swing at their start.