Roulette with prizes algorithm

106 Views Asked by At

I have a list of roulette items. F.e

[
   'id' => 1,
   'probability' => 50 // probability in %
],
[
   'id' => 2,
   'probability' => 20 // probability in %
],
[
   'id' => 3,
   'probability' => 10 // probability in %
],
[
   'id' => 4,
   'probability' => 5 // probability in %
],
[
   'id' => 5,
   'probability' => 1 // probability in %
];

So i need to write an algorithm that will describe behaviour of the roulette due to probabilities.

I have no ideas, can someone help me with an idea?

1

There are 1 best solutions below

0
On

I think if you study this you will get some Idea to write it yourself.

Fitness proportionate selection