CharlieHess / slack-poker-bot

A bot that deals Texas Hold'em games in Slack
MIT License
1.66k stars 207 forks source link

Shuffle algorithm is incorrect #21

Closed flakmonkey closed 9 years ago

flakmonkey commented 9 years ago

Sorry I didn't just create a pull request, but I'm on my mobile.

I believe the shuffle algorithm here is incorrect: https://github.com/CharlieHess/slack-poker-bot/blob/master/src/deck.js

My understanding is that you only want to swap the current card with cards that have a greater index in the deck, basically creating a shuffled and unshuffled part of the deck. It's explained better here: http://www.i-programmer.info/programming/theory/2744-how-not-to-shuffle-the-kunth-fisher-yates-algorithm.html

CharlieHess commented 9 years ago

Thanks for reporting @flakmonkey. Fixed here.