Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Progressive algorithm?

I hope this goes here; anyway i have this bit of code:
Code:
chance = rand($game_variables[2] *= 2)
and
Code:
if chance >= ($game_variables[2] * 0.25)

Im trying to make it the higher the varible the more times chance is >. Thanks
-Sobe
 
Your math is off. Let's say that game variable is 10 to start.

That means that you can get a number up to 20, and if that number is over 2.5 the condition is met. 20/2.5 = 8 meaning you have a 1/8 chance when the variable is 10. Let's say it is 20 now.

That means you can get a number up to 40, and if that number is over 5 the condition is met. 40/5 = 8 meaning that you have a 1/8 chance when the variable is 20.

If all you are doing is multiplying, you will preserve the ratio every time. Try something exponential or logarithmic instead.
 
Demon, I think your math is off too.
Although it's irrelevent, you are right about the constant ratio.

set variable 2 to 10

  chance = rand($game_variables[2] *= 2)

will set variable 2 to 20, and return a random number from 0-19

  if chance >= ($game_variables[2] * 0.25)

since variable 2 is now 20, we are checking against >= 5 (a ratio of 1/4)


Sobeman, what does game_variable 2 represent? a difficulty factor? The users pickpocket skill?
and in either case, what is the range?
 
Here's what I mean....
Code:
Lvl           % chance of success
-----       ---------------------
0            0
1            5%
50          75%
100         100%

or something like that
 
Ok, sorry it took me so long but here is what i got:

Code:
Level:    % Chance
1    45%
30    95%

Is that what you want or all the levels? 30 is the highest level. And i can post the script if needed.
 
It would help to have the % for level 15, or any other level in the middle. Otherwise, I have to assume it's linear.

chance = $game_variables[2].to_f * 1.725 + 43.275
if chance >= rand(100)
# success
end


Be Well
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top