random function: higher values appear less often than lower
math, php, random
Solution
Please, look at this beatiful article: http://www.redblobgames.com/articles/probability/damage-rolls.html
There are interactive diagrams considering dice rolling and percentage of results. This should be very usefull for you.
Pay attention to this kind of rolling random number:
roll1 = rollDice(2, 12);
roll2 = rollDice(2, 12);
damage = min(roll1, roll2);
This should give you what you look for.
Problem
I have a tricky question that I've looked into a couple of times without figuring it out. Some backstory: I am making a textbased RPG-game where players fight against animals/monsters etc. It works like any other game where you hit a number of hitpoints on each other every round. The problem: I am using the random-function in php to generate the final value of the hit, depending on levels, armor and such. But I'd like the higher values (like the max hit) to appear less often than the lower values. This is an example-graph: How can I reproduce something like this using PHP and the rand-function? When typing `rand(1,100)` every number has an equal chance of being picked. My idea is this: Make a 2nd degree (or quadratic function) and use the random number (x) to do the calculation. Would this work like I want? The question is a bit tricky, please let me know if you'd like more information and details.