The requirements for the lottery algorithm are as follows: 1. Can control the probability of winning the lottery 2. With Randomness 3. It is best to control the number of prizes 4. According to the user ID or IP, mobile number, QQ number and other conditions to limit the number of lottery Early on these require
The php winning probability algorithm can be used for scratch cards, big turntable, and other lottery algorithm. The php winning probability algorithm can be used for scratch cards, big turntable, and other lottery algorithms. The usage is very simple. the code has a detaile
I set the probability of the award for 0, what does that mean? This means that no matter how much the lottery draws, no one will ever get the premium sedan. When the organizer flips the remaining blocks each time, the participant will find that the first prize may be just under a number in the box next to the draw, blaming their bad luck. Is it really bad luck? In fact, when the participant flipped that block, the program has decided on the award, w
: This article mainly introduces the php lottery algorithm weight. if you are interested in the PHP Tutorial, refer to it.
Function getReward ($ total = 1000) {$ win1 = floor (0.12 * $ total)/100); $ win2 = floor (3 * $ total)/100 ); $ win3 = floor (12 * $ total)/100); $ other = $ total-$ win1-$ win2-$ win3; $ return = array (); for ($ I = 0; $ I
Php lottery
second is not, and the third is not. The last one must be. This algorithm is simple and highly efficient. The key is that it has been used in our previous projects, especially in projects with large data volumes.
Next we will use the PHP configuration award.
The Code is as follows:
$ Prize_arr = array ('0' => array ('id' => 1, 'prize' => 'tablet pc', 'V' => 1 ),'1' => array ('id' => 2, 'prize' => 'digital camera ', 'V' => 5 ),'2' => array ('id' => 3
PHP winning probability algorithm, can be used for scraping cards, large turntable and other lottery algorithm. The usage is very simple, the code has the detailed comment explanation, can understand at a glance
Php/** Classical probability algorithm, * $PROARR is a pre-set array, * Assuming array is: Array (100,20
A lottery algorithm is implemented by the interval distribution of random numbers. Accept a list that contains the odds of winning a prize and return the prize.
Define an abstract award category first.
Public abstract class Abstractprize {
/**
* Prize probability * *
private double probability;
Public double getprobability () {return
probability;
}
public void s
sedan, but I set the prize probability of 0, which means what? This means that no matter how much the lottery draws, no one will ever get the premium sedan. When the organizer flips the remaining blocks each time, the participant will find that the first prize may be just under a number in the box next to the draw, blaming their bad luck. Is it really bad luck? In fact, when the participants flipped that block, the program has decided on the award, w
PHP lottery Probability algorithm
*/* Different probabilities of the lottery is the principle of 0 to * (the proportion of total) of the interval block * block based on the proportion of goods accounted for the whole, and then according to the random number of seeds to produce a certain number of 0-* * To determine the number of the interval, the interval corres
The PHP lottery algorithm is now available for a lottery activity nbsp; the probability of winning the prize is as follows: First Prize 5% second prize 10% third prize 60% participation prize 25% my thoughts are very stupid: I have a random number ranging from 0 to, and then divide the interval according to the winning probability nbsp; first prize 96-100 secon
This article will share with you the php winning probability algorithm, which can be used for scratch cards, big turntable, and other lottery algorithms. The usage is very simple. the code has a detailed description, which can be understood at a glance. For more information, see. First, complete the PHP process in the background. The main task of PHP is to configure the awards and the corresponding winning
Do site classes sometimes get an activity or something to allow users to participate, not only to attract users to register, but also improve the user activity of the site. At the same time to participate in the user will get a certain prize, there are 100% winners, there is a certain probability of winning, big such as the ipad, iphone5, small in the Q currency what the Then we in the program will inevitably design to the algorithm, that is, accordi
PHP winning probability algorithm, can be used for scraping cards, large turntable and other lottery algorithm. The usage is very simple, the code has the detailed comment explanation, can understand at a glancePHP/** Classical probability algorithm, * $PROARR is a pre-set array, * Assuming array is: Array (100,200,300
Do site class sometimes get an activity or something, to let users participate, both to attract users to register, but also improve the user activity of the site. At the same time to participate in the user will receive a certain prize, there are 100% of winning, there is a certain probability of winning, big such as the ipad, iphone5, small in a Q currency or something. Then we will certainly design the algorithm in the program, that is, in accordanc
Original: http://blog.csdn.net/dongsg11200/article/details/24607877PHP winning probability algorithm, can be used for scraping cards, large turntable and other lottery algorithm
/*
* Classical probability algorithm,
* $PROARR is a pre-set array,
* Suppose array is: Array (100,200,300,400),
* Start is
This article to share is the PHP winning probability algorithm, can be used for scraping cards, large turntable, such as lottery algorithm. The usage is very simple, the code has the detailed annotation explanation, a look is understood, has the need the small partner reference under.
We finish the process of PHP backstage, PHP's main work is responsible for the
Php lottery probability algorithm
/** The lottery drawing principle with different probabilities is to divide the 0 to * (total proportion) intervals based on the proportion of the entire item, then, the random number seed is used to generate a number in 0-* to determine the range in which the number falls, and the interval corresponds to the item drawn. * The r
Php lottery and random ad algorithm we will first complete the PHP process in the background. The main task of PHP is to configure the awards and the corresponding winning probability, when the front-end page clicks a box, it will want PHP to send ajax requests in the background. then, the background PHP will give the winning result through the probability algorithm
What a better lottery algorithm for almighty Gods.
Reply content:
What a better lottery algorithm for almighty Gods.
return False
This is what I wrote earlier. Online with the popular is two algorithms, the probability is too high. Had to return to the textbook, and directly put all the winning ball and jammin
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.