sandalle / minecraft_bigreactor_control

Minecraft BigReactor Computercraft Control Program
MIT License
76 stars 41 forks source link

Actively Cooled Reactor Control #43

Open Rhodizzle opened 9 years ago

Rhodizzle commented 9 years ago

Hey guys,

Just got this set up on an active reactor with four turbines attached. I would like to suggest some logic to adjust the control rods based on a target steam production. Basically, I can set the steam production target for say, 8000mB/t and the program would automatically rise/lower the control rods to reach that point.

The only programmatic challenge that I see is that the reactor only reads the mB/tick that is able to be drawn out, which means that if I had a goal of 8000 mB/t for my four turbines, any control rod insertion that produced that or higher would read as producing 8000mB/t.

Anyways, awesome job and keep up the good work!

sandalle commented 9 years ago

Thank you, Rhodizzle, for this and your other report with where in the code the issue was, that helps. :)

Would the target steam mB/t be total steam from all actively cooled reactors, or per reactor? It'd be easier, in the code, to do per reactor as each reactor we'd just dial the rods until the reactor is producing at least that much steam (as close as we can get with auto-adjust).

For total steam mB/t for all connected reactors, we should not assume that all reactors are the same size (as people typically build small reactors at first to get Babby's First Power, and then build larger as they get more resources) and we shouldn't be asking them to re-build or decommission non-comformant reactors. :) We can get the rod # count per reactor and use that to scale, something like:

targetSteam
foreach reactor in activeReactor do
  currentSteam += producedSteam[reactor]
done

if currentSteam > targetSteam do
  foreach reactor in activeReactor do
    reactor.rodControl += adjustment * (1/reactor.numRods)
  done
fi

Should be, the more rods in a reactor, the less of an adjustment is made to approach target steam. The actual math would use some auto-adjust scaling for approaching the temperature without always bouncing, or avoiding it as much as possible.

Thoughts? Ideas?

Rhodizzle commented 9 years ago

Hey Eric,

Thanks for responding. It'll be a little more tricky than that I think. You'll have to excuse my ignorance as to computercraft code. I've got some programming experience outside of this but haven't ever written my own computercraft program.

If you are using this program to manage a combination of multiple actively cooled reactors as well as turbines, the steam output in mB should be numTurbines * 2000. The gotcha is that if the current configuration on the reactor is capable of outputting more steam the display, and I assume that the computercraft api query comes back similarly, only shows what the current turbines connected to that reactor are capable of consuming. Meaning that you can have your reactor set to potentially output 9000mB of steam, but if you only have four turbines, the reactor will appear to only make 8000. The logic for tuning would then have to slowly withdraw control rods until maybe three successive checks show the intended steam output, then insert until it drops, then withdraw by 1 and hold there. Once it's reached that point, assuming the reactor configuration doesn't change, that control rod insertion corresponds to the given steam output. If the number of turbines changes, some routine will have to re-initiate this cycle to determine the necessary control rod insertion for the intended steam output.

Because of this, i think it's best to have the user, either through config file or monitor interface, adjust the intended steam output per reactor if they have multiples. Here's my best pseudocode:

targetSteam for each reactor in activeReactors: get targetSteam from config file for Reactor i get currentSteam from Reactor i if currentSteam < targetSteam: increase control rod percentage by 1% wait 30 mins? if currentSteam = targetSteam record current controlRod insertion in config file as new target else targetSteam fi fi restart or whatever

Not sure if that helps or not, lol. Let me know if some of the logic isn't making sense...

RAnders00 commented 9 years ago

@Rhodizzle You can, for the time being, use this. Select "Actively cooled" and adjust the control rod insertion until you get the mb/t you want.

sandalle commented 9 years ago

@RAnders00 , that's a pretty slick tool, may I add a link to it in my code comments?

RAnders00 commented 9 years ago

@sandalle you may! I did not make it but it's pretty damp popular over at /r/feedthebeast, that's why I knew of it.