Results 1 to 3 of 3

Thread: QP: Random shuffle

  1. #1
    QP
    Guest

    QP: Random shuffle

    I've used this algorithm for random shuffing;

    Make array, Card(1, 2, ... ,n)
    for i=0 to n{
    Generate random number j
    Swap Card(i) and Card(j)
    }

    But I got suspicious about this algorithm recently when i did a test for new game. Is it enough for completely random shuffle? Or does anyone know more powerful algorithm?

  2. #2
    Norm Wattenberger
    Guest

    Norm Wattenberger: Careful

    That will create a bias if j is a number between 0 and n.

    for i = n - 1 to 1 step -1

    j = rnd * (i + 1)

    Swap cards(i), cards(j)
    next

    > I've used this algorithm for random shuffing;

    > Make array, Card(1, 2, ... ,n)
    > for i=0 to n{
    > Generate random number j
    > Swap Card(i) and Card(j)
    > }

    > But I got suspicious about this algorithm recently
    > when i did a test for new game. Is it enough for
    > completely random shuffle? Or does anyone know more
    > powerful algorithm?

  3. #3
    QP
    Guest

    QP: Thanks Norm:) That was wrong point. *NM*


Bookmarks

Posting Permissions

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

About Blackjack: The Forum

BJTF is an advantage player site based on the principles of comity. That is, civil and considerate behavior for the mutual benefit of all involved. The goal of advantage play is the legal extraction of funds from gaming establishments by gaining a mathematic advantage and developing the skills required to use that advantage. To maximize our success, it is important to understand that we are all on the same side. Personal conflicts simply get in the way of our goals.