top | item 10154663

Slack Poker Bot

318 points| CharlieHess | 10 years ago |github.com | reply

96 comments

order
[+] purephase|10 years ago|reply
While not a poker player, I can't help respect the why-the-fuck-not? aspect of this. Very cool.
[+] Wingman4l7|10 years ago|reply
The title confused me for a minute. In IRC chat circles, "bot" means a persistent software entity running in the channel, performing some task. In online poker circles, "bot" means software that automatically plays for you.
[+] lotyrin|10 years ago|reply
The attention to detail in spec output is exemplary.

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.

[+] GauntletWizard|10 years ago|reply
Possibly because running a bot client is much different from running a webserver. Dialing outbound to connect to slack is much easier than figuring out or configuring your own canonical URL, opening ports, etc.

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

[+] e12e|10 years ago|reply
Clearly the author is able to watch imgurl access logs... (or does imgurl list number of views for images? With good enough timing, that might be enough...)... ;-)
[+] flakmonkey|10 years ago|reply
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...

[+] todd8|10 years ago|reply
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.

[+] ajkjk|10 years ago|reply
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)

[+] shultays|10 years ago|reply
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?
[+] julbaxter|10 years ago|reply
Request: Planning poker integration to vote for story point
[+] hmate9|10 years ago|reply
Request: Battleship for Slack
[+] an4rchy|10 years ago|reply
Yes! Also, this might be a new genre of slack integrations.. games.... :lightbulb:
[+] 0xCMP|10 years ago|reply
Watch, soon we'll see articles about how "Slack built a platform..." and how the next big things are games for slack /s
[+] bbcbasic|10 years ago|reply
Or how Slack, like Facebook gets banned at many workplaces.
[+] AlexSolution|10 years ago|reply
Feature request: bitcoin integration
[+] kordless|10 years ago|reply
My thought exactly. But first, I'm containerizing it.
[+] cpr|10 years ago|reply
Nifty!

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.

[+] im3w1l|10 years ago|reply
There are unicodes for the cards, e.g. 🂶🃆. Does slack support color text?
[+] CharlieHess|10 years ago|reply
Totally considered this early on but wanted to stick to card images to add to the authenticity. Might expose this as an option later on, though.
[+] 0xCMP|10 years ago|reply
This is pretty awesome though. I got a list of games I want to make for our Python bot.

Number guess, blackjack, this, now maybe battleship...

[+] thomasfromcdnjs|10 years ago|reply
This is so good, I got it working in less than a minute. My team is going to have a blast with this.
[+] jakejake|10 years ago|reply
Cool! Do you have a public server that's running the bot, or do you just run it on your local machine?
[+] Pwntastic|10 years ago|reply
I can't seem to get it installed on windows 8.1... The lwip package in one of the other dependencies fails to build :( sad day
[+] CharlieHess|10 years ago|reply
Does the Heroku deploy work for you?
[+] binaryblitz|10 years ago|reply
Anyone having an issue with npm doing this: FATAL ERROR: JS Allocation failed - process out of memory
[+] Yhippa|10 years ago|reply
Super awesome! A few buddies and I use TriviaBot. So much fun. Can't wait to install this.
[+] companyhen|10 years ago|reply
As a new dev: How do I get npm install to run? I'm on step 4 of the instructions.
[+] kelyvin|10 years ago|reply
Make sure you have node and npm installed on your machine. (You can check by running "npm -v" from the command line, if you don't see anything, then take a quick google search on how to install it).

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!