random numbers to make simple bingo game

Hi people.

I do a simple game of Bingo in Director.

1 generate a random number up to 75; Number = Random (75)
2. check whether this number is on the list
3. If it is not the number is valid and code executed to display "bingo ball.
4 Add the number to the list
and repeat.

Is this valid? Are there problems with this approach, IE. as the numbers are called, the random number generated is more likely to be on the list already if will quickly take a? OR y at - it another way to do this?

Thanks in advance

The problem with your approach will be obvious when you deleted a bunch of numbers already. What you will see is the number of times you have to repeat step 2 will develop whenever you shoot a ball of bing as the number of balls drawn increases. How I would approach the opposite...

1. create your list of numbers from 1 to 75, procedurally at the beginning:

bingoList =]
Repeat the witih j = 1 to 75
bingoList.add (j)
end repeat

-Gives us a list containing the numbers from 1 to 75.

2. now, all you have to do is to generate a random number based on the number of items in the list and then remove this from the list:

listCount = bingoList.count
bingoBallPosition = random (listCount)
-get the value of ball bingo at the position in the list:
bingoBall = bingoList [bingoBallPosition]
-remove this bullet list number
bingoList.deleteAt (bingoBallPosition)

You'll have to do other things such as the definition of the bingoList as a global variable or property based on how you code your project...

You may want to be present in a moviescript upwards if you are a novice programmer, you can call the managers of anywhere in your project... If you would probably create an newGame Manager who would set up your list (and other things)...

-moviescript

Global bingoList, bingoBall

on newGame
bingoList =]
Repeat the witih j = 1 to 75
bingoList.add (j)
end repeat
end newGame

on getBingoBall
listCount = bingoList.count
bingoBallPosition = random (listCount)
-get the value of ball bingo at the position in the list:
bingoBall = bingoList [bingoBallPosition]
-remove this bullet list number
bingoList.deleteAt (bingoBall)
-do other things here like the bingo ball display
end getBingoBall

Tags: Director

Similar Questions

  • How to make random numbers

    Please Dear Sirs,
    I would like to create random numbers
    is there any function in oracle to make random numbers?
    waiting reply
    Thanks for all the people here
    Yasser

    Yasser,

    You can use the DBMS_RANDOM package. For more details, look at the thread http://www.psoug.org/reference/dbms_random.html

    Kind regards

    Manu.

  • Random numbers, not so much to chance

    I use a simple piece of code I found online to create a random number between two numbers

    new Random().nextInt(6-1)+1);
    

    I am trying to create random numbers for dice.

    Everything seems to work fine, but the numbers are not that random. I have a loop configuration to display the code above 50 times and it will make a loop over and over again the same number. Here is an example of the results

    1,1,1,1,1,1,4,4,4,4,2,2,2,2,2,1,1,1,1,1

    Therefore, it is quite difficult to create a type of yahtzee game when you always roll a yahtzee on the first roll lol.

    Is there something I'm missing here?

    I agree that the Random function generates only numbers random nickname and there are interesting ways of the algorithm of seeds, I believe that in this case, the problem is that Random is not used correctly.  I think that random is intended to be used as shown in the following fragment.  I also think that random is perfectly satisfactory for use in this case, so I would not personally recommend looking for another algorithm.

    Random myGenerator = new Random(System.currentTimeMillis());
    String thrown = ""; // Yes, this should be a StringBuffer....
    for ( int i = 0; i < 50; i++ ) {
        thrown = thrown + Integer.toString(myGenerator.nextInt(6)+1) + ", ";
    }
    System.out.println("Thrown: " + thrown);
    

    Here is the result of a few tracks:

    Lift: 5, 6, 2, 3, 1, 5, 3, 5, 4, 1, 5, 6, 3, 3, 6, 6, 5, 5, 3, 5, 1, 6, 6, 2, 1, 5, 5, 1, 6, 5, 5, 2, 5, 3, 6, 6, 5, 3, 5, 1, 2, 5, 1, 6, 2, 3, 1, 3, 2, 6,
    Lift: 4, 1, 4, 1, 5, 3, 5, 3, 2, 4, 3, 2, 5, 3, 4, 4, 3, 4, 2, 3, 2, 3, 1, 2, 2, 4, 5, 1, 5, 6, 2, 6, 6, 1, 1, 4, 5, 3, 4, 5, 6, 6, 6, 5, 6, 6, 2, 4, 5, 4,

    Edit: updated to fix the sample code fragment andgive output.

  • How LabVIEW can generate random numbers according to any pdf or histogram?

    I would like to know if there is a VI that generates a set of random numbers according to any probability density, the probability mass function or the graph histogram (this without explicitly knowing the function).

    Thank you.

    Acoustic wrote:

    I would like to know if there is a VI that generates a set of random numbers according to any probability density, the probability mass function or the graph histogram (this without explicitly knowing the function).

    If you have a given arbitrary distribution, you can simulate random data of thesholding mapping in the integral standard service with a simple random number 0... 1.

    This old post of mine should show you the General procedure and more details. (Is there even an former example). Of course, make sure that the desired function is all positive, of course.

  • Another problem of random numbers

    I say 'Other' because there is an existing thread of random numbers on the first page of this forum, but it is unresponsive to my problem.

    I'm generates names for an array of objects. I have an array of words (strings) to the choice. I use Math.random () * 151 to select indices array of two words. I want to check that the two chosen integers are not the same before assigning the name to the object. Then, I want to check to make sure that none of the two objects have the same name. Simple, right? Here is the code:
        for(int i=0;i<numStars;i++){
            ok=true;
            do{
            int part1=(int)(Math.random()*151);//first index
            int part2=(int)(Math.random()*151);//second index
            if (part1==part2){//make sure they're not the same number
                ok=false;
                System.out.println(part1+" "+part2);
            }else{
                stars.name=new String(starName[part1]+" "+starName[part2]);
    for(int j=0;j<i;j++){
    if(stars[i].name.equals(stars[j].name)) {//make sure no two stars have the same name
    ok=false;
    System.out.println(stars[i].name+" "+stars[j].name);
    }
    }
    }
    }while( ok==false);
    )//end of for loop


    The problem is, if integers part1 and part2 are equal in one pass through the do loop, they remain identical in each subsequent pass. The number doesn't stay the same, but whatever part1 is, part2 is always the same thing. This is only true after matching up one time. It's possible for it to run without ever hitting a duplicate.

    I changed it to ensure that part1 and part2 weren't covering the same range of numbers, and the same error started happening in the lower for loop that compares one object's name to another. This second-level error doesn't occur when part1 and part2 both cover the full range.

    Edited by: 800048 on Oct 11, 2010 3:17 PM

    Edited by: 800048 on Oct 11, 2010 3:25 PM

    800048 wrote:
    The problem is that if whole part1 and part2 are equal in one pass through the do loop, they remain identical in each subsequent pass.

    I don't think it's possible with the code you have posted.

    What will happen, however, given that you set never ok = true once part1 and part2 become unequal, is if they are equal in the first pass through the do / while loop, you will never get out of this loop.

    It is also unnecessary and bad form to use == or! = with the value true or false

    // bad
    x == true
    x != false
    
    // good
    x
    
    // bad
    x != true
    x == false
    
    // good
    !x
    
  • Random numbers appearing in messages

    I am running Firefox 4.0.1 on 64-bit Windows 7 and every time that I post on a forum or send a Gmail account, it adds random numbers at the end of my entry. I tried using Chrome and it doesn't do this, what's the problem?

    You paste content or add a signature?

    Start Firefox in Firefox to solve the issues in Safe Mode to check if one of the extensions of the origin of the problem (switch to the DEFAULT theme: Firefox (Tools) > Add-ons > appearance/themes).

  • Medium-sized random numbers

    So what I need to do, is to generate a series of random numbers. I've got that.

    However, the tricky part is that I need to average the random number and the previous 3 numbers random and exit on a waveform graph.

    Any help or pointers would be great. Thank you

    Simple as pie. He called a VI means Pt by PT. set your buffer to 4 and it will be an average intensity absorbed with the last 3.

  • Division of random numbers, see if the result is an integer.

    Simple and yet impossible to find an easy way around it.

    I have 2 RANDOM numbers, I'm dividing them, and I want to see if the result is an integer or not. Basically, I need to know if the divison of random numbers 2 is an integer.

    Who wants KUDOS?

    /SPAW

    Use Quotient and remains, check if the remainder is 0.

  • My PC randomly freezes while I play all games

    Hi I have still a problem with my new PC I am building there are not 5 months. It worked fine for the first 3 months and after that I started having some problem when I played the games. at any point randomly in the middle of a game my screen will go black, sometimes it flashes blue for like half a second and goes black again but my keyboard and mouse are always on but are inadmissible. I tried to apply all updates, and he repeats to me miss me a bus USB USB controller driver and windows can't find the driver. and when I have to reset my PC because of the accident he takes a long time to restart... what should I do?

    Hello

    (1) do you have made no changes before this problem?

    (2) are you facing this problem while playing games Microsoft or any other game?

    (3) have tried to update the video drivers on the computer?

    Method 1: Run the troubleshooter in the link mentioned below which applies to windows 7 as well and can help you to fix the issue connects to USB devices and the latest video drivers on the computer. Tips for solving problems of USB devices

    http://Windows.Microsoft.com/en-us/Windows-Vista/tips-for-solving-problems-with-USB-devices

    Method 2:

    Automatically get recommended drivers and updates for your hardware

    http://Windows.Microsoft.com/en-us/Windows7/automatically-get-recommended-drivers-and-updates-for-your-hardware

     

    Method 3: Restore the system

    You can also try to restore the system to apply the previous changes.

    How to do a system restore?

    http://Windows.Microsoft.com/en-us/Windows7/products/features/system-restore

    Method 4: You can also set options to disable automatic restart in case of failure, and make sure you provide the blue screen of death (BSOD) error message if you encounter the same problem again. You can also check the event log information and identify the exact error.

    For more information, see the below link.

    http://Windows.Microsoft.com/en-us/Windows7/update-drivers-recommended-links

    Hope this information helps.

  • Need help with a simple basketball game.

    Hi im new here and I need help with what makes this simple basketball game.

    Im trying to recreate this this video game. I'm not sure if it uses as2 or as3

    If someone could help me make a game like this or point me to a link on how to do it would be greatly appreciated.

    AS2 is used in the video.  If you have other issues, please post in the forum AS1/AS2.

  • random numbers in a textfield?

    Hi all thx for reading and I hope you can help

    I create a game for children, which shows them how to tell the time

    I need to put two random numbers in a textfield one for hours and one for the minutes

    so that I can get the app to say show me 13:45, for example

    However, I don't want to include the time of 12:00, because that's where the clock will start and defeated the purpose

    the clock is 24 hours, from 1 to 24 hours

    00-60 minutes

    Ive looked everywhere on how to do it but could not find an answer

    at the moment I have a textfield that displays the time as the user adds hours etc that I intend to hide

    while I can tell if this textfield random number is equal to the textfield time then correct display and so on

    How could I go about this?

    any help is appreciated

    Thank you

    fonzio

    Then just replace 0 with 24

    return (hour == 0 ? 24 : hour) + ":" + (minute < 10 ? "0" : "") + minute;
    

    --

    Kenneth Kawamoto

    http://www.materiaprima.co.UK/

  • Random numbers and generate funds

    Hello.

    I would like to create a very simple equation random addition.

    I have: 3 boxes of dynamic text (r1_txt, r2_txt, a1_txt)

    I want the first two random numbers and 'a1_txt' to display the sum of the first two random numbers.

    Everything is perfect to the point of adding the two numbers and drop the answer in a1_text. What should I do for my last line of code?

    Thanks for your help!

    random numbers
    1.
    function randomNumbers (min:Number, max: Number) {}
    var Results:Number = Math.floor (Math.random () * max) + min;
    return results;
    }

    2.
    new_mc.addEventListener (MouseEvent.CLICK, showRandomnumber);

    3.
    function showRandomnumber(event:MouseEvent):void {}
    r1_txt. Text = randomNumbers (1,100)
    r2_txt. Text = randomNumbers (1,100)
    a1_txt. Text = Number (r1_txt.text) + Number (r2_txt.text);
    }

    Your showRandomnumber() function has a few problems.  TextFields working with channels, so whatever it is assigned to a textfield must be a string value.  You should actually get errors for the first two lines.

    function showRandomnumber(event:MouseEvent):void {}
    r1_txt. Text = String (randomNumbers (1,100));
    r2_txt. Text = String (randomNumbers (1,100));
    a1_txt. Text = String (Number (r1_txt.text) + Number (r2_txt.text));
    }

    If you change which is not fix things, then look to your textfields to the problem

  • Choosing random numbers and unique serveral

    Hello

    I would select 9 random numbers of a series we'll say 1-20. They cannot repeat and each must be recorded in a different variable P1 - P9.

    Any ideas?
    Thank you

    Make a table of numbers 1 to 20.
    Mix the table.
    Remove as many numbers as you need.

    Search the forums for shuffle learn how to mix the table.

  • I use numbers to make files, but other people could not open, why?

    I use numbers to make files, but other people could not open, why?

    Hi Annie,.

    Only numbers can open a document in numbers. Excel cannot.

    In addition, there are several versions of numbers that work on a Mac. Older versions will be not open newer versions.

    What version of numbers do you run?

    What applications are the other people running?

    If other people are running Excel, you can export your document numbers to Excel (Menu > file > export to... > Excel). The export will not be perfect, but they will be able to open it and read it.

    More information, will lead to a solution.

    Kind regards

    Ian.

  • The value of the seed of the generator of random numbers in Matlab node

    Hi all

    I need to use random variables inside a Matlab Labview Commsuite node. I generate with the randn() function. Is it possible to put the seed of the random number generator such as the random numbers are reproducible?

    Hi Steve,.

    You can use randn ('seed', seeds) to initialize the random number generator. The seed must be a positive integer value. For example, randn ('seed', 3). In addition, this seed is global within the entire application. This means that if the randn() function is called MathScript multi-node that could run in parallel, random results are not guaranteed to be the same after you change any part of your code. But you should always get the same results for repeated passages of the same code.

Maybe you are looking for