Answer the question
In order to leave comments, you need to log in
How to implement roulette?
It became interesting how all these roulettes work on sites, as well as how all this is protected from substitution.
A banal example is a generated array of values.
For example, we have unique values:
From them we form a unique array of values for the game:
items = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
items_for_game = [3, 4, 4, 7, 1, 9, 10, 1, 4, 7, 6, 2, 9, 8, 2, 2, 10, 3, 6, 4 6, 4, 8, 9, 10, 4, 3, 6, 2, 4]
<input type="radio" name="items" value="тут номер из массива выше">
Answer the question
In order to leave comments, you need to log in
The server gives out the id of the picture and it decides which number will fall out, and torsion is just for beauty...
1. the server gives out the required number,
2. the roulette spins to the maximum and starts to rotate at maximum speed (it is even possible that it is very slow - this is not important),
3. the braking animation is positioned at the desired degree of the closed wheel so that at the moment of stopping it falls out ( as it were))) the desired number (which the server has already issued), and from that moment on, the roulette wheel starts to slowly stop according to the formula, falling exactly on this number.
4. Honesty: generating a series of numbers along with the order of the drop, hashing this sequence with a "salt", outputting the hash and the length of the series (number of spins) before the game starts. After the end of a series of spins - showing the "salt" and the whole series of numbers so that people can check according to the public, well-known hash formula.
The main question is "How to get rid of fraud?"
The answer to it is that all decisions must be made by the server and only on the basis of reliable data (which can only be changed by the server itself).
The rest is the implementation details of the interface.
And even in this case, you can find weaknesses if you try, for example, the dependence of the dropped numbers on the current time.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question