Wind Generators : is this math for production rate correct?

  • According to my read-through of the source code, a wind generator produces height*windstrength/750 every tick. Windstrength initially starts with a value between 10 and 20, average of 15.


    So, initially, a wind generator will make 2.56 EU/tick, with a bonus of up to 1.5.


    There is another function called "update wind" that initially has a 1/10 chance of increasing wind by 1 and a 1/10 chance of decreasing wind by 1.


    Here's the interesting part : if wind goes over 20 or under 10, the variable that allows it to increase or decrease becomes smaller, making a future increase or decrease less likely. In the long, long run those variables will go to zero and wind will no longer change. Hmm this could be a serious bug.


    Anyways, median wind production is 2.56 EU/tick, day and night, with bonuses for rain and thunder. I tried to compute what those bonuses are, but Notch's code for randomizing weather is somewhat complex. Assuming it is raining or thundering 10% of the time, with equal probability for either (it seems to be from the code), that means that these weather bonuses make the median wind income roughly 2.65.


    Solar, by comparison, only works when it is daytime, which is exactly 1/2 of the time. Assuming bad weather occupies 10% of the time, that means that solar produces a per panel income of 0.45 EU/tick.


    I'd like to calculate more precisely how much bad weather works out to be, but as I said, Notch's code is headache inducing.


    One more thing : there is a chance that wind can get over 20, and so during a thunderstorm only there is a 1 in 5000 chance, the dice rolled every 128 ticks that the blades will fly off and be dropped as 0-5 iron ingots and the wind generator is replaced with a generator.

  • Err, i have already made a detailed post on how they work.


    http://forum.industrial-craft.…ad&postID=26800#post26800


    They start with 10 to 19, not 10 to 20. Right there is the first mistake. I get the feeling most of your details are off because of that. But i shall read the rest.



    EDIT: You are correct about the wind gen being replaced with a generator... I had just missed that little part. Thought is was replaced by air.

  • Cadde : thanks. Every one of those errors was that I didn't know that rand.nextInt(x) is a value from 0 to x-1, not from 1 to x.


    Absolute max chance of a generator breaking, with the new information that wind caps at 31, is 3 in 5000. Since production can get as high as 7.936 (31*128/750) and 7.936-5 = 2.9. An integer rolled from 0 to 4999 will be less than or equal when it rolls 0, 1, 2 so a 3 in 5000 chance max.


    Ah, it needs a cable...forgot about that.


    Ah, I see the real error : ACTUALLY, there is an 11% chance of a wind INCREASE every tick and only a 9.79% chance of a wind DECREASE.


    That's because each time the wind increases, it won't decrease. What this means is, wind is going to have a tendency to get stronger more often than it gets weaker.


    The probabilities are simple to understand : for a wind increase, you have to roll an 11 in 100. For a wind decrease, you have to roll an 11 in 100 but you only get to roll if you DIDn't roll an 11 in 100 for a wind increase : so it's actually 0.89*11% = 9.79%.


    Honestly, my probability and stats class didn't cover how to handle this situation as far as I can recall, but an unbalanced system like this essentially has a positive derivative pulling the average number upward. I *think* the mean will be 21.05, because at 21.05 the probabilities finally balance and the chance of it going up equals the chance of it going down.


    Ah but now the math gets really advanced. There's a probability gradient because above 21.05 the chance of the wind staying high goes down sharply. Similarly, below 10 the chance of the wind staying low also goes down sharply. These probability gradients mean the wind will NOT spend half of it's time above 21.05, so the mean wind speed has to be somewhere lower. I don't know how to compute probability gradients without just writing a computer program to simulate them.

  • Update : hacked together a matlab script.


    With 500,000 runs, the average wind value is 18.1721. (matlab took several minutes on a 4.1 ghz overclocked i7 to do that many runs lol...it is a VERY VERY slow script)

  • Well, you have java so why not just copy the related code into a new project and run that 5 million times? Still wouldn't take as long as matlab :D