News for hackers. Stuff that matters.
Re:Slack Poker Bot by flakmonkey on Tuesday September 01, 2015 @05:29PM (#10155886)
Am I correct in saying that the shuffle algorithm is flawed? It looks to me like it swaps each card iteratively with a random card in the deck. This means that some cards are likely shuffled more times that others, and some sequences are then more common than others.

https://github.com/CharlieHess/slack-poker-bot/blob/master/s...

Re:Slack Poker Bot by CharlieHess on Tuesday September 01, 2015 @06:01PM (#10156090)
Re:Slack Poker Bot by avree on Tuesday September 01, 2015 @06:20PM (#10156197)
Since you already have the card images, any chance of having it deal actual card images versus the abbreviated format?

I can look into doing this myself and submitting a PR after I get home, as well.

Re:Slack Poker Bot by CharlieHess on Tuesday September 01, 2015 @08:22PM (#10156717)
Are you talking about the hole cards that are DM'ed to you? That's a good suggestion; feel free to file an issue.
Re:Slack Poker Bot by todd8 on Wednesday September 02, 2015 @02:35PM (#10161148)
For those interested, here is the reasoning from a combinatorics perspective. There are 52! different arrangements of a deck of cards. To see this, note that in any arrangement there are 52 locations for the Ace of Spades, once that choice is made there are 51 locations for the next card to end up in and so on until the last card must go in the only open location. Hence there are 52 factorial arrangements of cards in to a deck.

Shuffling, by swapping each card with any of the 52 other spots produces 52^52 (i.e. 52 * 52 * 52 * ...) arrangements. How can this be when there are only 52! (i.e. 52 * 51 * 50 * ...) possible arrangements. The answer is than many of the arrangements generated by this shuffling technique end up with the cards in the same order. This follows from the pigeon-hole theorem since 52^52 > 52!

Furthermore, we know that 52^52 is not a multiple of 52! (to see this realize that, for example, 11 divides 52! but not 52^52). Therefore, some bad shuffle generated arrangements will occur more than others and, consequently, that bad shuffle algorithm does not produce a "fair" shuffle.

Re:Slack Poker Bot by ajkjk on Tuesday September 01, 2015 @05:36PM (#10155927)
Yes, you're correct. It should swap with cards that are strictly at later positions in the deck:

Deck.getRandomInt(index+1, numberOfCards)

instead of

Deck.getRandomInt(0, numberOfCards)

Re:Slack Poker Bot by shultays on Wednesday September 02, 2015 @06:09AM (#10158294)
Does this add a bias though? If I took first card in deck and swap it a hundred times more than others how would that make a difference?
Re:Slack Poker Bot by dalore on Wednesday September 02, 2015 @07:14AM (#10158456)
Yes it does. http://blog.codinghorror.com/the-danger-of-naivete/

It's random but some results are overrepresented so more likely to occur. If you knew this and bet on this over time you would gain an advantage