Page 2 of 2 FirstFirst 12
Results 26 to 27 of 27

Thread: Generating Non Recurring Random Numbers

  1. #26
    Join Date
    Aug 2007
    Location
    England
    Posts
    734
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    This is what i'm using and it works perfectly..
    Code:
    Procedure ShuffleCards;
    var
    i,A: Integer;
    begin
      SetLength(RandomDeck, 53);
    
      for i := 0 to high(RandomDeck)do
        RandomDeck[i] := i;
    
      for i := 0 to High(Card) do
      begin
        A := Random(high(RandomDeck));
        Card[i].Position := RandomDeck[A];
        DeleteValueInIntArray(RandomDeck, A);
      End;
    end;
    The truth finally came out...


  2. #27
    Join Date
    May 2008
    Location
    Here :p
    Posts
    194
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    from my blackjack script :P

    Code:
    procedure suffledeck;
    var
      TDeck: Array [1..52] of TCard;
      I, T: Integer;
      Done: Boolean;
    begin
      for I := 1 to 52 do
      begin
        done := false;
        repeat
          T := (Random(52)+1);
        //  writeln(T);
          if TDeck[T].Number = 0 then
          begin
          //  writeln(I);
            TDeck[T] := Deck[I];
            done := true;
          end;
        until done;
      end;
      for I := 1 to 52 do Deck[I] := TDeck[I];
    end;

Page 2 of 2 FirstFirst 12

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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