playMaker

Author Topic: Chance of success logic from percentage.  (Read 1110 times)

Aaddiction

  • Full Member
  • ***
  • Posts: 166
Chance of success logic from percentage.
« on: July 21, 2019, 06:21:06 AM »
Could somebody steer me in the right direction how to do the following.

We have a chance of success between 1% and 99%. How to make in PM that the higher the percentage the higher the chance of success and vice versa?

Thore

  • Sr. Member
  • ****
  • Posts: 480
Re: Chance of success logic from percentage.
« Reply #1 on: July 21, 2019, 07:03:33 AM »
Your idea is a bit unclear, which might be a conceptual problem. I understand this as such: there’s first a chance of success between 1% and 99%. Use random float action to find what the actual success rate is first, store in a variable. Next, you roll a second variable, also with random float, and also store this as a result variable. Finally, float compare whether the result is lower than the success  rate. You can do it also with integers (int) like in offline dice games, roleplaying games etc.

Aaddiction

  • Full Member
  • ***
  • Posts: 166
Re: Chance of success logic from percentage.
« Reply #2 on: July 21, 2019, 08:25:45 AM »
Thanks. Concept is clear, here's how I did it.

1. Player buys upgrades and those upgrades rise the chance of success in percentage from 0% to 99%. So here we have int1 - actual chance.

2. We define int2 - hypothetical chance, which is a random int between 0-99.

3. We compare int1 and int2 and if int1 is equal or lower/higher than int2 we fail/succeed.

So yes, it's what you described as well.