1 Reply Latest reply on May 9, 2007 11:31 AM by Newsgroup_User

    random numbers to make simple bingo game

    storypeddler
      Hi folks.

      I am making a simple Bingo game in Director.

      1. generate a random number up to 75; Number=random(75)
      2. check if this number is on a list
      3. if not the number is valid and code executed to display the "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 has more likelihood of being on the list already so will speed take a hit? OR is there another way to do this?

      Thanks in advance
        • 1. Re: random numbers to make simple bingo game
          Level 7
          A better approach would be to make a list of the numbers 1-75. Randomly
          select a number from the list and remove it from the list. This way each
          time you select a number you are guaranteed that it had not been selected
          before. When a new game starts, you just repopulate the list with the
          numbers 1-75 again.


          "storypeddler" <webforumsuser@macromedia.com> wrote in message
          news:f1t1gp$htd$1@forums.macromedia.com...
          > Hi folks.
          >
          > I am making a simple Bingo game in Director.
          >
          > 1. generate a random number up to 75; Number=random(75)
          > 2. check if this number is on a list
          > 3. if not the number is valid and code executed to display the "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 has more likelihood of being on the
          > list
          > already so will speed take a hit? OR is there another way to do this?
          >
          > Thanks in advance
          >
          >