-
September 11th, 2010, 10:33 PM
#16
Re: Probability Function
I forgot to put in the (-25) roll penalty for the StealChance, however you have a general idea of what I've accomplished.
-
September 12th, 2010, 12:42 AM
#17
Re: Probability Function
Originally Posted by jmcewan
I was responding to dglienna's comment.
I do understand what you are saying, I'm just not sure I want to randomize the numbers.[...]
Isn't that just what you've tried to do with that code you posted?
Originally Posted by jmcewan
Hello again,
Just and update. I've managed to create the function without any shortcomings. I did it as follows:
StealChance = RandomClass.Next() % 96
BallHandlingChance = RandomClass2.Next() % 98
if( StealChance >= BallHandlingChance)
{
Console.WriteLine.("Great steal by " +defenderName);
} else{
Console.Write.(+ defenderName " gets called for the reaching foul");
}
What do you guys think?
Now you've got it all randomized.
The random class has a much more convenient method with the signaturepublic virtual int Next(
int maxValue
); and another onepublic virtual int Next(
int minValue, int maxValue
); -- so you don't need to do what you've done with %.
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.
Last edited by TheGreatCthulhu; September 12th, 2010 at 12:45 AM.
-
September 12th, 2010, 10:48 PM
#18
Re: Probability Function
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?
Rob
-
Ohhhhh.... Old McDonald was dyslexic, E O I O EEEEEEEEEE.......
-
September 13th, 2010, 05:21 AM
#19
Re: Probability Function
Originally Posted by rliq
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?
I think the OP just tries to create a simulation/game like app, not some player performance analyzer. The stats are predetermined, possibly in a more or less arbitrary way.
-
September 13th, 2010, 05:48 AM
#20
Re: Probability Function
Originally Posted by jmcewan
Imagine a basketball game where players move/act based on stats. A defender may have his STEAL rating at 94, and the offensive player has a BALL HANDLING rating of 98. I would like to know if a function exist that calculates the probability of the defender taking the ball from the offensive player. Like if (based on the stats) the defender has a 31% chance of making the steal.
Hmm ... maybe:
chanceOfSteal = (1 - ballHandlingRating) * stealRating
0.0118 = (1 - 0.98) * 0.94
-
December 6th, 2010, 07:50 PM
#21
Re: Probability Function
Originally Posted by Zaccheus
Hmm ... maybe:
chanceOfSteal = (1 - ballHandlingRating) * stealRating
0.0118 = (1 - 0.98) * 0.94
How would you then use the result?
-
December 7th, 2010, 05:50 AM
#22
Re: Probability Function
That's up to you - what do you want to do with the 'chance of steal' ?
-
December 9th, 2010, 09:25 AM
#23
Re: Probability Function
Originally Posted by Zaccheus
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.
-
December 9th, 2010, 12:07 PM
#24
Re: Probability Function
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.
-
December 9th, 2010, 12:44 PM
#25
Re: Probability Function
Originally Posted by FransBotes
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.
Saw it, it is great stuff. I think I will use this method to simulate the game engine.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|