Results 1 to 3 of 3

Thread: Real random numbers? Any way to seed this?

  1. #1

    Thread Starter
    Hyperactive Member voidflux's Avatar
    Join Date
    Jun 2003
    Location
    Brockway, PA
    Posts
    290

    Resolved Real random numbers? Any way to seed this?

    Hello everyone!!

    I'm making a poker game, and I need a way to make the dealing randomized, Right now I have a [4][13] array of card objects, and my get function is the following:

    I can't have the random numbers be anyting other than
    0 to 3 for the columns and 0 to 12 for the rows, because anyhting else will be out of range.


    Code:
      public void getCard(int howMany)
      {
        Random r = new Random();
        
        
        while(howMany != 0)
        {
          int col = r.nextInt(4);
          int row = r.nextInt(13);
          
          if (theDeck[col][row].inDeck) {
            theDeck[col][row].inDeck = false; //take the card out of the deck
            System.out.print(theDeck[col][row].faceType +
                             theDeck[col][row].cardValue + " ");
            --howMany;    
          }
          else
            continue;
        }
        System.out.println();
      }
    Is there anyway to make this more random?


    Thanks!
    Last edited by Dilenger4; Oct 7th, 2004 at 05:05 PM.
    C¤ry Sanchez
    Computer Science/Engineering
    @ Penn State
    IBM.zSeries Intern
    Mandriva 2007

  2. #2

  3. #3

    Thread Starter
    Hyperactive Member voidflux's Avatar
    Join Date
    Jun 2003
    Location
    Brockway, PA
    Posts
    290
    Thanks, I ran my program about 10 times and it gives me random different random numbers each time, so i'm just not going to mess with the seed.
    C¤ry Sanchez
    Computer Science/Engineering
    @ Penn State
    IBM.zSeries Intern
    Mandriva 2007

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width