I forgot to put in the (-25) roll penalty for the StealChance, however you have a general idea of what I've accomplished.
Printable View
I forgot to put in the (-25) roll penalty for the StealChance, however you have a general idea of what I've accomplished.
Isn't that just what you've tried to do with that code you posted?
Now you've got it all randomized.
The random class has a much more convenient method with the signaturepublic virtual int Next(and another one
int maxValue
);public virtual int Next(-- so you don't need to do what you've done with %.
int minValue, int maxValue
);
The convention is to write the names of the variables with a lowercase starting letter. I assume that RandomClass is an instance of the Random class? If so, it is an object, so the name you gave it is a bit misleading.
Anyway, you don't need to, or should use two random objects in this case - one will do just fine; the only thing you need to do is to call the Next(...) method twice.
The whole idea was to define an event such a "a steal has occurred", to define a way to calculate it's probability from the stats (in whatever way suits your needs), and to run a check against this probability, by generating a random integer number between 0 and 99 [including 99, which gives a total of 100 possibilities].
Or you could alternatively divide the probability you had expressed in percentage by 100, and then call rnd.NextDouble(), which would give you a greater precision.
P.S. And, when I say "to define" - I don't mean in code, but conceptually.
I assume the Steal and Handling probabilities have been calculated for players playing against exactly the same opposition, otherwise the %ages are pointless. I have 100% ball handling, having only picked a ball up once and got past one 12 year old. Does that mean I can get past a pro who has 68% steal?
That's up to you - what do you want to do with the 'chance of steal' ?
Perhaps credit the defender with +1 steal and change possession. Sounds like the perfect implementation of Finite State Machines.
I'm looking into another possible way to achieve what I want. I would like to compare the two teams' stats then have it generate realistic statistical output.
On the other forum i have posted you a new message. Hope it helps its more or less an complete way to simulate your game.