318 points · by CharlieHess · 11y ago · 96 comments
Uploading to Imgur for displaying card images to users seems like a strange choice, though. Why not have the bot serve its own images up over HTTP and attach URLs to itself? I could even imagine a badges.io style image preparation microservice that could be shared by several playing-card based bot apps.
On the other hand, preparing hands as a single image seems a bad way of doing this; Does the slack API only allow a single image per conversation? I agree with your preparation microservice idea - There should be (and probably are several) a service that allows you to specify a poker hand as a query string and get back an image of the hand. More simply, though: A webfont and https://en.wikipedia.org/wiki/Playing_cards_in_Unicode
Unicode has playing card codepoints (the full 52) and playing card house codepoints (️, ️, ️, ️).
Edit: What the hell? Hacker News stripped the Unicode characters?! https://news.ycombinator.com/item?id=10156894
> preparing hands as a single image seems a bad way of doing this
I don't believe there's another way to display them inline?https://github.com/CharlieHess/slack-poker-bot/blob/master/s...
I can look into doing this myself and submitting a PR after I get home, as well.
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.
Deck.getRandomInt(index+1, numberOfCards)
instead of
Deck.getRandomInt(0, numberOfCards)
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
Shoot, I'll just do it myself.
Edit: https://github.com/CharlieHess/slack-poker-bot/issues/14 https://github.com/CharlieHess/slack-poker-bot/issues/22
Glad I'm not the only one.
Why not define a bunch of custom emoji, one for each card, and use those instead of the big graphics at each turn? Would save massive bandwidth.
Number guess, blackjack, this, now maybe battleship...
Run "npm install" in the folder directory where the package.json is visible. In this case, if you cloned or extracted this project, it would be in the slack-poker-bot folder.
Hope that helps!