Skip to content

Instantly share code, notes, and snippets.

@themartorana
Forked from jakeobrien/gist:5503948
Last active April 23, 2023 21:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save themartorana/c744a9cc0fdcd02521e0 to your computer and use it in GitHub Desktop.
Save themartorana/c744a9cc0fdcd02521e0 to your computer and use it in GitHub Desktop.
Flyclops Domino! Bone Randomization Code
// for Unity (C#)
public static void Shuffle<T>(this List<T> list)
{
System.Random rnd = new System.Random();
int n = list.Count;
while (n > 1) {
n--;
int k = rnd.Next(n + 1);
T obj = list[k];
list[k] = list[n];
list[n] = obj;
}
}
@themartorana
Copy link
Author

Hi! Dave here. This is the actual code that we are using to randomize bones.

list is the List<T> of bones.

If you have any questions or comments about this, let us know!

@oellington
Copy link

Hey Dave. We've exchanged emails before, and I think I've told you that your code is solid above. However, the biggest issue that Domino! has is that Microsoft Unity's randomization function is pretty bad. In fact, it's horrible. And that shows in the hands that you receive. I know it's hard to simulate physical, real, table dominoes. In a real game, you just can't have two players receive hands with 6 of the same domino. In 20+ years of playing, I've never seen that. But it happens with Domino!. I'm in a team tournament right now, and one of my players received 6 of the same bone. He was unsurprisingly happy. However, his opponent did also. Unreal. Highly improbable (in real life).

As the admin of the fastest growing Flyclops Domino community on Facebook, I see the jokes and frustration all the time. I experience it. I think we all know that Microsoft (and PHP/Linux) use PRNGs and not TRNGs. The art of selecting a domino on a table would be comparable to a TRNG action. Has there been an effort to move away from Microsoft's System.Random() to a TRNG-type system?

Still and always will be a huge fan of Domino! and my community is almost at 2000 strong.

Thanks,
Owen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment