Community

 
Jump Menu:
Post Reply
Page 1 of 180  •  1 2 3 4 5 6 ... 180 Next
Switch to Forum Live View The Shuffler Thread For a New Generation
8 years ago  ::  Oct 20, 2005 - 4:56PM #1
bubba0077
  • Volunteer Community Lead
  • blame me for the weather
Date Joined: Feb 27, 2002
Posts: 9,792
I thought it was about time to create a new shuffler thread to throw out a lot of the chaff and consolidate all the 'important' information in the first post where people will hopefully see it.

First, the [O]fficial explaination of how the MTGO shuffler works, originally provided by Chris Green, president of Leaping Lizards (who developed the thing), preserved by muriban and passed on to Vitalogy1994 who posted it in the last incarnation of this thread: 

ChrisG]MTGO's Shuffle Algorithm...get the technical low down... March 15, 2002 by Chris Green  wrote:

MTGO's Shuffle Algorithm...get the technical low down... March 15, 2002 by Chris Green  A technical description of Magic Online's shuffler and random number generator.  The core random number generator used is "Algorithm A", from Knuth's "Art of Computer Programming", sec 3.2.2. This is a fast, easy to implement random number generator. Knuth states that it has "consistently produced reliable results, in extensive tests since its invention in 1958."  I first implemented this generator in 6502 assembly code in 1981 or so, and it has never failed me.  The implementation of this generator used in our libraries uses the standard constants (24,55). Because this is somewhat fewer than the number of bits required to produce all possible hands, it was augmented with another generator using the constants (33,68). This yields a total state size of 3936 bits. Both generators were combined so that the random number calls used in our library could still return the same sequence of numbers when initiated by our old programs (never know when we might have to rebuild a new version of Centipede3D for the Dreamcast :-) ).  In MTGO, random numbers are initialized by the game servers. When a new game is started, the random number state is seeded via /dev/random, which uses hardware delays for a source of true random data. In addition, whenever a packet is received from a user by the game server, the lower order bits of the system CPU's clock cycle counter are added into the random state.  Shuffling is performed by swapping every card in the deck with a random other card in the deck. This is algorithm "P" for shuffling from Knuth. The book contains a formal analysis of its randomness. The 32 bit random values returned by the basic random number function are mapped into the appropriate range by fixed point multiplication.  One of our programmers, Sergey, was not satisfied that the random number generator wasn't mana-screwing him, and so performed the following test:  The shuffler has no idea what is a land and is not a land, so if there is any unnatural clumping of lands, it must be based upon the initial ordering of the deck. So he performed the following test:  Create in memory a virtual deck of 20 "1"s, representing lands, and 40 "0"s representing non-lands. Put all the "lands" first and then all the "nonlands". Apply the shuffler.  Perform the same test, except with lands and nonlands interleaved before shuffling.  Perform each test multiple millions of times. After each test, count the sizes of land/non-land clusters and keep a running total of each.  Compare the results from the millions of runs with the deck ordered with all lands together versus the interleaved one. The results were the same to within a minuscule fraction of a percent.  In addition, he wished to verify that shuffling extra times would have no effect. If it did have an effect that would mean that the shuffle was insufficiently random. He performed this test and got the same statistics from one shuffle as from many.



The primary reasons people think the shuffler isn't random:

  • Most people are under the misconception that a random distribution means an even distribution. Random distributions have natural clustering.
  • Experience doesn't match what they are used to in paper; there are many poor (human) shufflers out there. When confronted with *actual* randomness of the computer shuffler, they blame the computer instead of their own faulty shuffling practices. In reality these people have been unknowingly cheating for a long time.
  • People tend to remember significant events more vividly then normal occurrences. They remember the times when they were horrifically flooded but forget all the normal games in between.

 Now, some required reading before you post if you want any hope of people caring what you say:
  • Stats 101: Am I Shuffling Enough - Or Correctly, For That Matter? - A very good explaination of what a randomized deck *should* look like; it's far different than many think. [Provided by Vitalogy]
  • The Wikipedia Entry on Knuth Shuffling. Here's a code snipet using the method [adapted from code posted by many]:
    deck = new Card[n] ; an array of Card objects n long (syntax: first element is element zero)
    do i=0,n-1
        swap = Random(i,n-1) ; random integer between i and n-1 (inclusive) generated as described by ChrisG
        temp = deck[swap] ; store the card to swap into current position for a moment
        deck[swap] = deck[i] ; move the current card where the swapped card was
        deck[i] = temp ; move the swapped card where the current card was  delete(temp) ; cleanup
        delete(swap) ; cleanup
    end do
  • Actual OpenBSD code for a strong random number generator using hardware noise. Includes underlying theory [pointed out by slpalmer]
  • Article describing similar complaints in bridge since they switched to computer-generated deals 30+ years ago. Turns out (suprise!) people weren't shuffling correctly so their expectations were wildly different than should occur with truely random deals. Also discusses how many shuffles are necessary to randomize a deck. [Provided by me]
  • Math Magic Made Easy - Excel™ spreadsheet I created that computes various Magic math situations. One of the pages produces the probability of drawing so many cards of a certain type (listed as lands) out of N cards drawn from a deck of your choice. This should be useful if you want to try and disprove the shuffler by drawing a set number of cards from your deck instead of comparing the number of land clumps in the full deck as SCG does. [Shameless self-plug]

If you want to try and disprove the randomness of the shuffler, here are some things you MUST do:
  • Use EVERY trial you do, don't pick-and-choose 'bad' ones and note them.
  • Run a BARE MINIMUM of 1000 trials.
  • Read up on statistical confidence intervals and learn how to conduct a T-Test, Z-Test or similar.

Xtofyr recorded data for several thousand hands. The initial results appeared skewed and prompted more thorough testing by elf. These later tests show the shuffler to behave as expected. Full results are here.

The probability for common MTG cases:

Seven Cards (opening hand):                 
# land drawn 16/40 17/40 18/40 23/60 24/60 25/60
0 01.86% 01.31% 00.91% 02.67% 02.16% 01.74%
1 11.55% 09.20% 07.20% 13.84% 12.10% 10.51%
2 27.36% 24.55% 21.61% 28.56% 26.94% 25.22%
3 31.92% 32.30% 32.02% 30.29% 30.87% 31.18%
4 19.76% 22.61% 25.28% 17.82% 19.64% 21.44%
5 06.47% 08.40% 10.62% 05.80% 06.93% 08.19%
6 01.03% 01.53% 02.19% 00.97% 01.25% 01.60%
7 00.06% 00.10% 00.17% 00.06% 00.09% 00.12%
2-5 85.50% 87.85% 89.52% 82.46% 84.39% 86.02%

Six Cards (mulligan):               
# land drawn 16/40 17/40 18/40 23/60 24/60 25/60
0 03.51% 02.63% 01.97% 04.64% 03.89% 03.24%
1 17.72% 14.90% 12.35% 20.03% 18.07% 16.21%
2 33.22% 31.37% 29.16% 33.38% 32.47% 31.37%
3 29.53% 31.37% 32.74% 27.49% 28.87% 30.07%
4 13.09% 15.69% 18.42% 11.78% 13.37% 15.03%
5 02.73% 03.71% 04.91% 02.49% 03.07% 03.71%
6 00.21% 00.32% 00.48% 00.20% 00.27% 00.35%
2-4 75.84% 78.44% 80.31% 72.64% 74.71% 76.48%

Eleven Cards (5th turn play/4th turn draw):             
# land drawn 16/40 17/40 18/40 23/60 24/60 25/60
0 00.1080% 00.0585% 00.0305% 00.2495% 00.1753% 00.1217%
1 01.3574% 00.8413% 00.5035% 02.3378% 01.7801% 01.3392%
2 06.7869% 04.8074% 03.2920% 09.1842% 07.5820% 06.1810%
3 17.8157% 14.4222% 11.2870% 19.9518% 17.8719% 15.7958%
4 27.2476% 25.2389% 22.5739% 26.6024% 25.8834% 24.8220%
5 25.4310% 27.0205% 27.6531% 22.8266% 24.1578% 25.1644%
6 14.7232% 18.0137% 21.1465% 12.8399% 14.8064% 16.7763%
7 05.2583% 07.4493% 10.0697% 04.7247% 05.9490% 07.3445%
8 01.1268% 01.8623% 02.9149% 01.1117% 01.5323% 02.0656%
9 00.1366% 00.2660% 00.4858% 00.1588% 00.2404% 00.3547%
10 <0.0001% 00.0193% 00.0416% 00.0124% 00.0206% 00.0334%
11 <0.0001% <0.0001% <0.0001% <0.0001% <0.0001% <0.0001%

NB: booster/tournament packs are NOT random, nor are they intended to be. They are created using card listings called print runs.
Past Discussion: Previous Shuffler Thread

If there is anything important you think I missed, let me know.

Credits: Everyone who has contributed their time to the rational discussion of the shuffler in various threads over the years.
Edit (23 Nov 05 19:05 UTC): Added 'Sweet-spot' total probabilities (at least 2 lands + 2 spells in opening hand) and probabilities for a mulliganed hand.
Edit (10 Jul 06 05:53 UTC): Added link to data provided by Xtofyr and Elf.
Edit (18 Jan 08 20:10 UTC): Updated FAQ reference
Edit (15 Mar 10 19:50 UTC): Reformatted with html tags
Magic Online Volunteer Community Lead. • Also assisting the Paper Magic area for the time being.
I'm trying to make my official VCL posts in purple

You posted saying my thread was moved/locked but nothing happened.      Spoiler: Show
Unfortunately, VCLs do not currently have the tools necessary to take moderation actions directly. VCLs submit their actions to ORCs, who then actually perform the action. This processing can take between a few minutes and several hours, depending on how busy/attentive the ORCs are.


If you see something that needs VCL attention, please use this thread (MTGO) or this thread (paper) to make a request and a VCL will look at it as soon as possible.  CoC violations should be reported to Customer Service using the "report post" button. Please do not disrupt the thread by making requests of either kind in-thread.

General MTGO FAQ


Yes, the Shuffler is Random!
The definitive thread on the Magic Online shuffler.

Magic Math Made Easy
Draw probabilities, Swiss results, Elo ratings and booster EV

Event EV Calculator
Calculate the EV for any event with a fixed number of rounds and prizes based on record

Dual means two. A duel is a battle between two people. Lands that make two colors of mana are dual lands. A normal Magic battle is a duel.

Thanks to PhoenixLAU for the awesome avatar!

QuotablesSpoiler: Show
"While a picture is worth a thousand words, each lolcat actually produces a negative wordcount." -Ith

"I think "Highly Informed Sarcasm" should be our Magic Online General motto." -Ith

"Sorry, but this thread seems just like spam. TT is for off-topic discussion, not no-topic discussion."
-WizO_Kwai_Chang

"Stop that! If you're not careful, rational thinking may catch on!" -Sax

"... the only word i see that fits is incompitant." -Mr44 (sic)

"You know a thread is gonna be locked when it gets to the hexadecimal stage." -Gathion

"It's a good gig" - Gleemax

"I tell people often, if you guys want to rant, you've certainly got the right to (provided you obey CoC/ToS stuff), and I don't even really blame you. But if you see something you think needs changing a well thought-out, constructive post does more to make that happen." - Worth Wollpert
Quick Reply
Cancel
8 years ago  ::  Oct 20, 2005 - 4:59PM #2
CrazyBlend
Date Joined: Dec 15, 2003
Posts: 2
No! Noooooooooo!!!
Quick Reply
Cancel
8 years ago  ::  Oct 20, 2005 - 5:04PM #3
WizO_Kwai_Chang
  • Bunnies should be considered dangerous weapon
Date Joined: Nov 26, 2004
Posts: 199
Yes! Yessssssssssssss!!!

Thanks to bubba for compiling the vast knowledgebase that was present in the previous incarnation of the Shuffler thread. Hopefully it will help players understand how the shuffler works.

All we need now is Grog to chime in.
Quick Reply
Cancel
8 years ago  ::  Oct 20, 2005 - 5:05PM #4
natedawg
  • Regulators!
Date Joined: Nov 29, 2003
Posts: 5,005

bubba0077]Credits: Everyone who has contributed their time to the rational discussion of the shuffler in various threads over the years.


I vote for giving entertainment credits to those who contributed irrationa wrote:

Credits: Everyone who has contributed their time to the rational discussion of the shuffler in various threads over the years.[/quote]
I vote for giving entertainment credits to those who contributed irrationally. :D

4. Don't speak dumb, or you'll be struck dumb.

Remember, the name of the game is heads I win, tails you lose.
Quick Reply
Cancel
8 years ago  ::  Oct 20, 2005 - 5:15PM #5
bubba0077
  • Volunteer Community Lead
  • blame me for the weather
Date Joined: Feb 27, 2002
Posts: 9,792

natedawg]I vote for giving entertainment credits to those who contributed irrationally. :D


I usually just point and wrote:

I vote for giving entertainment credits to those who contributed irrationally. :D[/quote]
I usually just point and laugh.

Magic Online Volunteer Community Lead. • Also assisting the Paper Magic area for the time being.
I'm trying to make my official VCL posts in purple

You posted saying my thread was moved/locked but nothing happened.      Spoiler: Show
Unfortunately, VCLs do not currently have the tools necessary to take moderation actions directly. VCLs submit their actions to ORCs, who then actually perform the action. This processing can take between a few minutes and several hours, depending on how busy/attentive the ORCs are.


If you see something that needs VCL attention, please use this thread (MTGO) or this thread (paper) to make a request and a VCL will look at it as soon as possible.  CoC violations should be reported to Customer Service using the "report post" button. Please do not disrupt the thread by making requests of either kind in-thread.

General MTGO FAQ


Yes, the Shuffler is Random!
The definitive thread on the Magic Online shuffler.

Magic Math Made Easy
Draw probabilities, Swiss results, Elo ratings and booster EV

Event EV Calculator
Calculate the EV for any event with a fixed number of rounds and prizes based on record

Dual means two. A duel is a battle between two people. Lands that make two colors of mana are dual lands. A normal Magic battle is a duel.

Thanks to PhoenixLAU for the awesome avatar!

QuotablesSpoiler: Show
"While a picture is worth a thousand words, each lolcat actually produces a negative wordcount." -Ith

"I think "Highly Informed Sarcasm" should be our Magic Online General motto." -Ith

"Sorry, but this thread seems just like spam. TT is for off-topic discussion, not no-topic discussion."
-WizO_Kwai_Chang

"Stop that! If you're not careful, rational thinking may catch on!" -Sax

"... the only word i see that fits is incompitant." -Mr44 (sic)

"You know a thread is gonna be locked when it gets to the hexadecimal stage." -Gathion

"It's a good gig" - Gleemax

"I tell people often, if you guys want to rant, you've certainly got the right to (provided you obey CoC/ToS stuff), and I don't even really blame you. But if you see something you think needs changing a well thought-out, constructive post does more to make that happen." - Worth Wollpert
Quick Reply
Cancel
8 years ago  ::  Oct 20, 2005 - 6:42PM #6
Zinger314
  • Has Fury!
Date Joined: Aug 13, 2002
Posts: 1,046
I break dance while I do the shuffle.

Is that a problem?
Quick Reply
Cancel
8 years ago  ::  Oct 20, 2005 - 7:11PM #7
DrakeStorm
Date Joined: Mar 2, 2005
Posts: 12
Shouldn't you mention how the Server is a sentient being and that eventhough over the course of millions of sample shuffles the results are random, but on any one game, the Server can and will mana-hose or mana-screw the non-believers as they see fit.
Quick Reply
Cancel
8 years ago  ::  Oct 20, 2005 - 7:14PM #8
Tharion_wind
  • Commoner
Date Joined: Jul 25, 2002
Posts: 561
The Shuffler is broken. The shuffler is random. Human shuffling is better, more "realistic". The computer-based shuffler is truly random. Etc, ad naseum.

Grog is a pain to all of us. Either we just notice the manastarves/floods online more or it truly does impale us painfully.

I did some paper in 2002 and when we played - it was a 40% (24 land for 60 card deck) and never got manaflooded/starved as does happen in MTGO.

That being said, I played maybe 100 paper games then dove into MTGO. On average I do 100 MTGO casual games a week or more. So naturally wouldn't I get more flooded or starved with mana (by virtue of more games played)?

Inquiring minds would like to know the answer to this (and to those of you waiting to stamp 42 on this thread, I beat you to it).

Regards,
Tharionwind
Ponders if Grog ever could beat me in a PDC match.
Being challenged in life is inevitable, being defeated is purely optional.  Improvise (a solution), Adapt (to current situation), Overcome (any obstacle in your way) -- been working for the USMC since 1776.
Quick Reply
Cancel
8 years ago  ::  Oct 20, 2005 - 7:16PM #9
lathspel
  • Jawsome UnCon Prizewinner
Date Joined: Sep 22, 2003
Posts: 881
Bubba, bringing back this thread should guarantee you an EPOTM. Just think of the evil you could summon when you're not being helpful. :evillaugh

Me, the more I play, the less I hate the shuffler. Either I'm getting used to it, I'm building my decks with the right land, or possibly I'm becoming a better mulliganer. Most likely it's that last one.
Quick Reply
Cancel
8 years ago  ::  Oct 20, 2005 - 7:43PM #10
bubba0077
  • Volunteer Community Lead
  • blame me for the weather
Date Joined: Feb 27, 2002
Posts: 9,792

lathspel]Bubba, bringing back this thread should guarantee you an EPOTM. Just think of the evil you could summon when you're not being helpful.

Me, the more I play, the less I hate the shuffler. Either I'm getting used to it, I'm building my decks with the right land, or possibly I'm becoming a better mulliganer. Most likely it's that last one.


It's not like the former shuffler thread had vanished when I posted this (it was about the seventh non-sticky when I posted), I just thought it would be nice if a new one were started that had all the *good* technical information up front where everyone would see it. Not many people read every post in a 600+ post thread.

I'm (some would say unfortunately) firmly entrenched on the good team, and the evil team will NEVER pull me over to the dark side.

Now, if the naughty team had an opening... :pl wrote:

Bubba, bringing back this thread should guarantee you an EPOTM. Just think of the evil you could summon when you're not being helpful.

Me, the more I play, the less I hate the shuffler. Either I'm getting used to it, I'm building my decks with the right land, or possibly I'm becoming a better mulliganer. Most likely it's that last one.[/quote]
It's not like the former shuffler thread had vanished when I posted this (it was about the seventh non-sticky when I posted), I just thought it would be nice if a new one were started that had all the *good* technical information up front where everyone would see it. Not many people read every post in a 600+ post thread.

I'm (some would say unfortunately) firmly entrenched on the good team, and the evil team will NEVER pull me over to the dark side.

Now, if the naughty team had an opening...

Magic Online Volunteer Community Lead. • Also assisting the Paper Magic area for the time being.
I'm trying to make my official VCL posts in purple

You posted saying my thread was moved/locked but nothing happened.      Spoiler: Show
Unfortunately, VCLs do not currently have the tools necessary to take moderation actions directly. VCLs submit their actions to ORCs, who then actually perform the action. This processing can take between a few minutes and several hours, depending on how busy/attentive the ORCs are.


If you see something that needs VCL attention, please use this thread (MTGO) or this thread (paper) to make a request and a VCL will look at it as soon as possible.  CoC violations should be reported to Customer Service using the "report post" button. Please do not disrupt the thread by making requests of either kind in-thread.

General MTGO FAQ


Yes, the Shuffler is Random!
The definitive thread on the Magic Online shuffler.

Magic Math Made Easy
Draw probabilities, Swiss results, Elo ratings and booster EV

Event EV Calculator
Calculate the EV for any event with a fixed number of rounds and prizes based on record

Dual means two. A duel is a battle between two people. Lands that make two colors of mana are dual lands. A normal Magic battle is a duel.

Thanks to PhoenixLAU for the awesome avatar!

QuotablesSpoiler: Show
"While a picture is worth a thousand words, each lolcat actually produces a negative wordcount." -Ith

"I think "Highly Informed Sarcasm" should be our Magic Online General motto." -Ith

"Sorry, but this thread seems just like spam. TT is for off-topic discussion, not no-topic discussion."
-WizO_Kwai_Chang

"Stop that! If you're not careful, rational thinking may catch on!" -Sax

"... the only word i see that fits is incompitant." -Mr44 (sic)

"You know a thread is gonna be locked when it gets to the hexadecimal stage." -Gathion

"It's a good gig" - Gleemax

"I tell people often, if you guys want to rant, you've certainly got the right to (provided you obey CoC/ToS stuff), and I don't even really blame you. But if you see something you think needs changing a well thought-out, constructive post does more to make that happen." - Worth Wollpert
Quick Reply
Cancel
Page 1 of 180  •  1 2 3 4 5 6 ... 180 Next
Jump Menu:
 
    Viewing this thread :: 0 registered and 1 guest
    No registered users viewing