*Author

Random Number Generator https://elementscommunity.org/forum/index.php?topic=778.msg7769#msg7769
« Reply #12 on: December 15, 2009, 10:10:07 pm »

I'm not a Flashkit forumer, but does that forum have a PM system too? Has anyone tried to contact him there?

Offline Belthus

  • Full Member
  • ***
  • Posts: 482
  • Reputation Power: 1
  • Belthus is a Spark waiting for a buff.
Re: Random Number Generator https://elementscommunity.org/forum/index.php?topic=778.msg13563#msg13563
« Reply #13 on: December 20, 2009, 05:20:13 pm »
I notice that I almost always get the same False God in two consecutive matches. One more thing to check....

Delreich

  • Guest
Re: Random Number Generator https://elementscommunity.org/forum/index.php?topic=778.msg13565#msg13565
« Reply #14 on: December 20, 2009, 05:33:01 pm »
I notice that I almost always get the same False God in two consecutive matches. One more thing to check....
Streaks is typical randomness. Anyway:
The (good) Math.random() from actionscript is used for:
* choosing your opponent in level 2, 3 & 6

Delreich

  • Guest
Re: Random Number Generator https://elementscommunity.org/forum/index.php?topic=778.msg15561#msg15561
« Reply #15 on: January 04, 2010, 03:07:28 pm »
Deck shuffling uses the Fisher–Yates algorithm with actionscript random.
Wikipedia says it's a good idea:
http://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle (http://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle)
According to liebmann, the implementation isn't quite correct (based on v1.16).

Here's (part of) what (s)he had to say:
Quote from: liebmann
so instead of:
Code: [Select]
while (i < deckn) {
  j = Math.floor(Math.random() * deckn);
  temp = deckx[i]; deckx[i] = deckx[j]; deckx[j] = temp;
  i++;
}
something more like:
Code: [Select]
i= deckn;
while (i > 1) {
  j = Math.floor(Math.random() * i);
  temp = deckx[j]; deckx[j] = deckx[i-1]; deckx[i-1] = temp;
  i--;
}
In other words, the current implementation goes through all deck positions, picks any other random deck position and swaps the cards.
The correct implementation should only pick from positions that haven't been iterated over yet.

Delreich

  • Guest
Re: Random Number Generator https://elementscommunity.org/forum/index.php?topic=778.msg18044#msg18044
« Reply #16 on: January 15, 2010, 10:47:03 pm »
According to Zanz on chat, the built-in-to-flash RNG is now used for everything outside of PvP. Don't know any details about what is used in PvP, but it was something different, for desynch-avoiding purposes.
Shuffling is unchanged as yet, and deemed low priority, as the bias caused by that error shouldn't really be noticeable.

 

anything
blarg: