Trying to calculate accurate % out of variables
Posted: Sun Jan 14, 2024 1:55 am
Hello math majors! I'm playing with combinators and suddenly, I had an idea. If I could measure the percentage of my storage at all times, hook up combinators to my storage, and always have the circuit network display an accurate % no matter how many times I place more storages, it will take the variables and convert it into a %.
Setting the stage to make this easier to understand, let's say I plan on making a huge storage array of petroleum, well, to start, you need a storage tank, and the tank stores 25,000 units of fluid. A simple calculation can be explained as such: 25,000/250=100%, because 25,000 fills up the entire tank. Makes sense so far. With this simple calculation, I could also do 8000/250=32%. So 8000 is 32% of 25,000. Great!
Here's where it starts to become convoluted (at least for me anyways). I have installed now 3 more tanks, and have gotten a lot more petroleum to fill them up. Let's say I have 54,000 petroleum. 54,000/250=216%, which is another way of saying 216% of 25,000, even though my total storage is now 100,000. You could argue that I could change my equation to reflect my max storage as such: 54,000/1000=54% to keep the % accurate, but that requires manual work, which is not what I want to do. I want to automate the algorithm.
After some thinking, I tried x/y=P, the problem I have is, how do I figure out what the divisor(y) should be if x is the current amount of petroleum(not the total) and P is the percentage? If the factory must grow, then so must my brain. So in this example, I will always be building more storage tanks and always have more petroleum(x). I can't really use the number of storage tanks as a constant because it's not a constant, it's a variable.
So I changed up the formula. I got rid of x and now I have A/B/y*100=P, where A represents the current storage amount and B represents the total storage amount. The game knows by default how much petroleum(A) you have if you connect it to a circuit network, and calculating B is 25,000*B, now the equation becomes A/(25,000*B)/y*100=P. So if I do 25,000/(25,000*B)/y*100=P, I'll find out that y=1, great!
But how do I calculate this for chests? So far this algorithm works with liquids, but items in chests use different stacks. Iron ore for example is a 50 stack and red wire is a 200 stack. What algorithm would work for both liquid and solid storage? I'm currently trying to solve this, since this is an interesting puzzle to solve and would introduce a universal QoL combinator setup. If you have no idea what's going on, don't worry, neither do I. Just thinking about how I'm going to break down this formula into simple equations and putting it into combinators is giving me a headache.
Thank you for reading this info dump, and don't worry, I'm having fun doing this. I'm not suffering, I promise. Okay, maybe I'm suffering a little bit.
Setting the stage to make this easier to understand, let's say I plan on making a huge storage array of petroleum, well, to start, you need a storage tank, and the tank stores 25,000 units of fluid. A simple calculation can be explained as such: 25,000/250=100%, because 25,000 fills up the entire tank. Makes sense so far. With this simple calculation, I could also do 8000/250=32%. So 8000 is 32% of 25,000. Great!
Here's where it starts to become convoluted (at least for me anyways). I have installed now 3 more tanks, and have gotten a lot more petroleum to fill them up. Let's say I have 54,000 petroleum. 54,000/250=216%, which is another way of saying 216% of 25,000, even though my total storage is now 100,000. You could argue that I could change my equation to reflect my max storage as such: 54,000/1000=54% to keep the % accurate, but that requires manual work, which is not what I want to do. I want to automate the algorithm.
After some thinking, I tried x/y=P, the problem I have is, how do I figure out what the divisor(y) should be if x is the current amount of petroleum(not the total) and P is the percentage? If the factory must grow, then so must my brain. So in this example, I will always be building more storage tanks and always have more petroleum(x). I can't really use the number of storage tanks as a constant because it's not a constant, it's a variable.
So I changed up the formula. I got rid of x and now I have A/B/y*100=P, where A represents the current storage amount and B represents the total storage amount. The game knows by default how much petroleum(A) you have if you connect it to a circuit network, and calculating B is 25,000*B, now the equation becomes A/(25,000*B)/y*100=P. So if I do 25,000/(25,000*B)/y*100=P, I'll find out that y=1, great!
But how do I calculate this for chests? So far this algorithm works with liquids, but items in chests use different stacks. Iron ore for example is a 50 stack and red wire is a 200 stack. What algorithm would work for both liquid and solid storage? I'm currently trying to solve this, since this is an interesting puzzle to solve and would introduce a universal QoL combinator setup. If you have no idea what's going on, don't worry, neither do I. Just thinking about how I'm going to break down this formula into simple equations and putting it into combinators is giving me a headache.
Thank you for reading this info dump, and don't worry, I'm having fun doing this. I'm not suffering, I promise. Okay, maybe I'm suffering a little bit.