Controlling the probability of random pumping [C # | Random]

Source: Internet
Author: User
Tags range

Objective

About this algorithm may (certainly) have been invented, but I, my friends, my teacher before this is not know and can not think out, if you do not know, then include you: In this range was first proposed should be regarded as "invention"!! increase, reduce the probability of random pumping-my good friend Dippen three years ago an algorithm, I now take out to flourish. This algorithm can be used for random problem-solving, gambling machine control rate, even Tetris and other games, has a wide range of uses! And I hope I can help you!

Emphasize

On the basis of a random increase in the control of the probability of extraction, attention to randomness!!

Body

One, the text explanation:

To add a weight to each item of the collection to be randomly sampled, this weight is a random probability, for example, the probability of normal being pulled is 1, then set the weight of the item that you want to be pumped to 3 or 5, then randomly extract the items in the collection, multiply the random numbers by each item, and then sort!! Extract the first n items! You can find that the higher the weight is multiplied after a higher probability of being drawn in front, if the weight set to 0 will never be smoked!

Second, the application scene:

1. Random questions: If a test last year, then I hope that the probability of appearing this year is smaller or not appear, then I will be the weight of the title of a 0, this question will be in the future of the test randomly drawn in the question is never randomly pumped; and the other question B is this year's simulation test in a problem, I will this title increase to 5, According to the algorithm, then this topic in the next random extraction of the problem will be more than the common problem to raise several times!

2. Gambling machine: We know that the game room inside the gambling machine is adjustable, was adjusted after the rate of increase significantly or lower, I think this algorithm is suitable for interpretation. Suppose the gambling machine has 24 betting items to choose from, is a-Z each letter, according to the normal probability of each item weight is 1, the regulator can change the weight by dynamic to achieve increase or reduce the winning rate. If you cast three coins, selected A, B, C, the gambling machine according to the adjustment of the Machine division dynamically changed the weight of a, B, C, so that the lights turn 3-4 laps after the greater chance to stay in these three choices of less than one bonus.

3. Tetris: Everyone in the play QQ Tetris, sometimes obviously the higher the heap, out of things instead of Shun Yi, I think this algorithm can also achieve this effect. The computer can calculate the next optimal solution is the best way out or out of the corner, so you can adjust the weights to break the average occurrence of the probability to achieve this goal!

......

Related Article

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.