Generate random player strengths in a pyramid structure (PHP)

前端 未结 6 1778
醉梦人生
醉梦人生 2021-01-13 19:59

For an online game (MMORPG) I want to create characters (players) with random strength values. The stronger the characters are, the less should exist of this sort.

E

6条回答
  •  礼貌的吻别
    2021-01-13 20:32

    generate a random number between 0 and 40000, if its between 0 and 12000, assign strength 1, between 12000 and 22500 assign 2 etc.

    Edit: for progressive values between 0 and 10 use the square root of a random number between 0 and 100, then substract if from 10

    • rand -> strengh
    • 0-1 -> 9.9 -> 9 (1%)
    • 2-4 -> 9 -> 8 (2%)
    • ...
    • 81 - 100 -> 1 - 0 (19%)

    For results between 1.1 and 9.9 the formula would be in pseudocode)

    strength = 10 - sqrt(rand(1..79))

提交回复
热议问题