konceptum
konceptum
  • Threads: 33
  • Posts: 790
Joined: Mar 25, 2010
March 27th, 2013 at 10:09:48 PM permalink
Sometimes, I think too much about the math behind things that don't really matter.

Anyway, in a game, a couple of different situations arise, and I'm curious about various math behind it.

1) There's an input slot, and an output slot. Because of the limitation of the game, a stack of items is 64 items. So, you put as many items, up to a full stack, into the input slot. The machinery does some stuff, and there's a 1 in 8 chance per input item of something being placed in the output slot. The output slot can also only contain up to a full stack of 64 items.

So, most of the time, you put a full stack in the input slot. Wait, then retrieve whatever you can out of the output slot. Which averages around 8 items, obviously.

But, I'm lazy. I dump a full stack into the input slot. I don't want to remove from the output slot until I really need to. So, I keep dumping full stacks into the input slot. The mathematical question becomes: at what quantity of items in the output slot am probably going to lose items because the output slot becomes full?

So, if the output slot already contains 64 items, and I dump a full stack of 64 items into the input slot, there's no more room in the output slot. So whatever the machinery does, that gives the 1 in 8 chance of an item in input becoming an item in output, if it happens, I'm not going to get that item, since the output slot is full. If the output slot contains 63 items, then from the stack of 64 input items, I'll get 1, if any are produced, but I miss out on any others that get produced. And since the average is going to be 8, it seems like it would be "highly likely" that I would lose out on some items.

With an average of 8, then it seems like 56 items in the output slot gives me a pretty good chance of not losing any items. But it is possible that a full stack of 64 input items could produce more than 8, and thus there is some probability of me losing an item when the output slot can only contain 64 more items.

So, the easy part I can figure out. If the output slot contains 0 items, then there is a 0% chance that I will lose any items from the processing. On the other hand, if the output slot contains 64 items, then there is a 100% chance that I will lose any items from the processing, but that's only if any items are actually processed. I guess maybe I want to know, at what point do I have a 50% chance or greater of losing items. And, more importantly, how do I do the math to get to that point.

2) At a completely different part of the game, I come to a question about game balance. There are two pieces of machinery which perform similar functions. In Machine A, 1 item of input produces 2 items of output, every time. In Machine B, 1 item of input will sometimes produce 1 item of output, sometimes 2 items of output, and sometimes 3 items of output.

Now, the easy part is the simple math. If Machine B produces 1 output 50% of the time, 2 output 25% of the time, and 3 output 25% of the time, then the average is an output of 1.75. Which is less than Machine A's guaranteed output of 2. Most people would then say, only use Machine A. However, what if some other arbitrary game mechanic determined that the cost of using Machine A was greater than the cost of using Machine B? Said cost might be power usage. So the question is, how much more power usage should Machine A utilize over Machine B, in order to balance out the fact that Machine A has greater output, on average, than Machine B?

Anyway, I hope all of that makes sense. Reading back over it, I'm not sure if it does. I don't even know why I worry about random math that has no affect on anything. Perhaps it is because my brain is only half awake at the best of times.
MathExtremist
MathExtremist
  • Threads: 88
  • Posts: 6526
Joined: Aug 31, 2010
March 27th, 2013 at 10:28:56 PM permalink
Start by looking up the newsboy problem and then see where that leads.
"In my own case, when it seemed to me after a long illness that death was close at hand, I found no little solace in playing constantly at dice." -- Girolamo Cardano, 1563
ThatDonGuy
ThatDonGuy
  • Threads: 122
  • Posts: 6679
Joined: Jun 22, 2011
March 28th, 2013 at 7:06:29 AM permalink
I don't think there's an "easy" way of doing #1.

If I read the problem right, if you put A coins in, the probability of B coins being returned is (1/8)B x (7/8)A-B x C(A,B)
(where C(A,B) is the number of distinct combinations of B things drawn from a set of A)

For any particular number N of coins already in the output slot (from 0 to 64), you need to find the smallest number X (with X >
64 - N) such that, if you put X coins in, the probability of X coins returned + the probability of (X-1) coins returned + ... + the probability of (64-N) coins returned >= 1/2.
dwheatley
dwheatley
  • Threads: 25
  • Posts: 1246
Joined: Nov 16, 2009
March 28th, 2013 at 7:25:30 AM permalink
I think #1 is just the binomial distribution. Use binomdist( n , 64 , 1/8 , true ) in Excel, where n is the number of items that will pop out. You have a 59.3% chance of getting 8 or less, but only a 44.4% chance of getting 7 or less. Once you have only room for 7 items, you have > 50% chance of losing at least 1.

To reduce this chance to <1%, leave room for 15 items.
Wisdom is the quality that keeps you out of situations where you would otherwise need it
CrystalMath
CrystalMath
  • Threads: 8
  • Posts: 1911
Joined: May 10, 2011
March 28th, 2013 at 7:53:32 AM permalink
Do you get to see the output slot fill with every input stack or do you only know the amount in the output when you open it to empty it?

In a real world example, you would need to balance the cost of losing an item with the cost savings gained by the efficiency.
I heart Crystal Math.
konceptum
konceptum
  • Threads: 33
  • Posts: 790
Joined: Mar 25, 2010
March 28th, 2013 at 9:15:59 AM permalink
Quote: CrystalMath

Do you get to see the output slot fill with every input stack or do you only know the amount in the output when you open it to empty it?

In a real world example, you would need to balance the cost of losing an item with the cost savings gained by the efficiency.


You can sit and watch the output stack fill up, but it's a lengthy process, so that would be some time wasted doing it.
konceptum
konceptum
  • Threads: 33
  • Posts: 790
Joined: Mar 25, 2010
March 28th, 2013 at 9:16:50 AM permalink
Quote: dwheatley

I think #1 is just the binomial distribution. Use binomdist( n , 64 , 1/8 , true ) in Excel, where n is the number of items that will pop out. You have a 59.3% chance of getting 8 or less, but only a 44.4% chance of getting 7 or less. Once you have only room for 7 items, you have > 50% chance of losing at least 1.

To reduce this chance to <1%, leave room for 15 items.


Instinctively, I had been emptying the output when there was about 45 items in it, which is fairly close to your suggestion of 15.
MangoJ
MangoJ
  • Threads: 10
  • Posts: 905
Joined: Mar 12, 2011
March 29th, 2013 at 1:19:45 AM permalink
Quote: konceptum

2) At a completely different part of the game, I come to a question about game balance. There are two pieces of machinery which perform similar functions. In Machine A, 1 item of input produces 2 items of output, every time. In Machine B, 1 item of input will sometimes produce 1 item of output, sometimes 2 items of output, and sometimes 3 items of output.

Now, the easy part is the simple math. If Machine B produces 1 output 50% of the time, 2 output 25% of the time, and 3 output 25% of the time, then the average is an output of 1.75. Which is less than Machine A's guaranteed output of 2. Most people would then say, only use Machine A. However, what if some other arbitrary game mechanic determined that the cost of using Machine A was greater than the cost of using Machine B? Said cost might be power usage. So the question is, how much more power usage should Machine A utilize over Machine B, in order to balance out the fact that Machine A has greater output, on average, than Machine B?



It all depends on how you define your costs.

The strategy "only use Machine A" is correct if nothing but the input has some costs associated, since for same costs (i.e. for a simple input unit) machine A produces 2 output units while machine B produces 1.75 output units.

If the only cost comes from power (which now can be different for both machines), the break-even point is:
PowerA * 2 = PowerB * 1.75, or PowerA/PowerB = 0.785.
The result is, if machine B consumes power less than 0.785 the power of machine A, you should use machine B.

Now if both the input and the power consumption are costs to you, then obviously the best operation depends on the specific numbers you would assign as the costs.

In principle, all types of costs will influence your best stratevgy of machine usage. There might be time constrains (i.e. if you use both machines simulanteous, you could produce the output faster) - or you might want to reduce variances of your output. Some machines could be refitted for use in a different production line, i.e. you would want to use machine B (although it will be more costly than machine A) in order to reuse machine A in some other production line of a differnet product....


In my work place, for operation we need to cool certain parts of a machinery with water. Normally one would a closed-cycle system where the water, after passing by the hot parts, releases the heat to the environment by some kind of radiator. Instead, we just use the (cool) drinking water of an faucet, which after passing by the hot simply parts get discarded into the sink.
Obviously it would be better to reuse the water by the closed cycle system, but the cooling system needs a lot of electrical power. However our work place doesn't need to pay for water consumption, so the fresh drinking water is used. It all depends on the definition of your costs.
konceptum
konceptum
  • Threads: 33
  • Posts: 790
Joined: Mar 25, 2010
March 29th, 2013 at 10:02:31 AM permalink
Quote: MangoJ

It all depends on how you define your costs.
The result is, if machine B consumes power less than 0.785 the power of machine A, you should use machine B.



I think this will help in my mental thinkings for most of it. I'm not sure why I couldn't figure this out myself. Brain vapor lock, probably. This makes the most sense in terms of either power consumption, as you mentioned, or even in terms of consumables used during the processing itself. Such as drill bits or other tools parts used in manufacturing in a machine shop.

The other type of cost might be a startup cost. Perhaps both machines utilize the same costs during operation, it's merely the cost to purchase or build the machines that varies. In that case, I would assume that it might also depend on how long the machines are used for.
konceptum
konceptum
  • Threads: 33
  • Posts: 790
Joined: Mar 25, 2010
March 29th, 2013 at 10:15:48 AM permalink
Quote: MangoJ

In my work place, for operation we need to cool certain parts of a machinery with water. Normally one would a closed-cycle system where the water, after passing by the hot parts, releases the heat to the environment by some kind of radiator. Instead, we just use the (cool) drinking water of an faucet, which after passing by the hot simply parts get discarded into the sink.
Obviously it would be better to reuse the water by the closed cycle system, but the cooling system needs a lot of electrical power. However our work place doesn't need to pay for water consumption, so the fresh drinking water is used. It all depends on the definition of your costs.


Side note: Many, many, years ago, I was an accountant for a machining facility. They had a CNC machine which cooled down the bits using a closed-cycle system, except I believe the system didn't utilize straight water, but rather a water/coolant mixture of some type. However, the system was a bit on the old side, and would clog up frequently, causing consternation

One day, I was coming back from lunch, and noticed something unusual, so I went onto the machining floor. The lead machinest was running the CNC machine, and two other machinests were moving back and forth from the bathroom sink to the machine, cupping water in their hands. The cooling system had clogged again, but this was the first time I had seen this particular cooling methodology used. I went in to the manager's office and enquired if this was really a cost effective thing to be doing. (My accounting instinct had kicked in first.) He explained that it was. Primarily because it would take too long to unclog the cooling system, and the job had a deadline.

My second instinct was to head back to where I had lunch, and get two paper cups, and return to give to the two machinests carrying water in their hands. They looked at me as though I had invented sliced bread.

My third instinct was the purchase of a faucet adapter, a hose, and a tripod. Then, whenever the cooling system clogged up in the middle of the job, the adapter and hose was hooked up to the sink, the other end of the hose attached to the tripod, and utilizing two extra people to carry water back and forth was eliminated. I received a bonus for devising an "ingenius" way of saving the company money. Silly.
  • Jump to: