I am making a nuclear reactor and am having some difficulty with the math behind it.
Well The Ammount of math and trivial minute details of math in programming an nuclear reactor is aneurismatic. For example, when using a random number generator to decide when to cause a 'Fission' in the code I assign my upper and lower bounds on the random number (In this case those are 1 and 10, so any [random] Number between those two). Then I tell the code If the random number is greater than 'X' cause a fission and decrease the time until I try again for a fission. If the number is less than 'X' then I tell the code to increase the ammount of time until I try again for a chance of a fission. Well because Im working between 1 and 10 Obviously if 'x' is 2 for example, then there is a 20% chance that a fission will occur and I will slightly decrease the period of time until another fission takes place, so if I make 'X' 5 then its a 50% chance. Straight forward, right? well, not quite. My troubles arrise when if I set the control rod position to for example position 3 out of 20 (85% chance of a fission) The interval of time until another try at fission begins to increase to ridiculous levels and in some cases the reactivity stops because the ammount of time is so great.
Also, I need some method of storing values over time in a list of some sort so I can compare values over time, such as comparing the temperture form one tick to the current tick. This is so I can calulate the delta of temperature.
Is there any suggestions for how to resolve this?
Also, where and how is a good way to post the code for this? I would like to be able to provide people with some insight into where and what my code looks like for this in-order to illicit better help.
> It is a nice enough language...
I am sorry, what? What? VB? Nice? Even Java manges not to be that terrible. Might as well be using COBOL.
As for your random number, try using a linear feedback shift register. It has extremely good spread (there is a more technical term for this, but I am tired and can't remember it), making it ideal for this situation.
You probably also should specify a maximum upper value for the time to wait. Finally, increase your range a ton, I would increase it to the size of an integer and use that range to calculate where the cutoff point is. This guarantees quality randomness.
And yeah, use a vector/array/etc.
http://msdn.microsoft.com/en-us/library/vstudio/wak0wfyt.aspx