flaviooooo
Programmer
Hey all,
I have 2 questions regarding odds, which I hope someone can help me with:
1) How can I create a function which returns me the following: I have percentage and based on that percentage it gives me the value 1 or 0.
So for example I pass 75% to the function, so there is 75% chance the function will return me a 1 and 25% chance that it returns me a 0...
2) This one seems to be more difficult to me.
The base concept is that I'm trying to create some kind of racing simulation "game". I have 3 racers, who each have a percentage chance of winning the race.
Now I would to run a function, that will randomly rank them in the finish based on these percentages.
For example:
John has 50% chance of winning
Mike has 20% chance of winning
Eric has 30% chance of winning
Then the function would do it's thing and we would get a ranking:
1. Eric
2. John
3. Mike
Eric has beaten the odds, and won the race!
How do I start on something like this??
I have 2 questions regarding odds, which I hope someone can help me with:
1) How can I create a function which returns me the following: I have percentage and based on that percentage it gives me the value 1 or 0.
So for example I pass 75% to the function, so there is 75% chance the function will return me a 1 and 25% chance that it returns me a 0...
2) This one seems to be more difficult to me.
The base concept is that I'm trying to create some kind of racing simulation "game". I have 3 racers, who each have a percentage chance of winning the race.
Now I would to run a function, that will randomly rank them in the finish based on these percentages.
For example:
John has 50% chance of winning
Mike has 20% chance of winning
Eric has 30% chance of winning
Then the function would do it's thing and we would get a ranking:
1. Eric
2. John
3. Mike
Eric has beaten the odds, and won the race!
How do I start on something like this??