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.
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.
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
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...)... ;-)
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.
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.
why not use a generic chatbot like errbot (http://errbot.net [shameless plug alert]) and get all the backends (hipchat, IRC, XMPP etc...) for free ?
there are existing poker AIs in python to integrate with: https://github.com/mikaelbr/AI-Poker-Player
Tried it - it crashed for both games we tried. Then again, installing node on my box was a mess - we have some sort of proxy on apt-get that insisted on installing an old version. I probably screwed up somehow.
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.
[+] [-] vinothgopi|10 years ago|reply
[+] [-] enahs-sf|10 years ago|reply
[+] [-] shade23|10 years ago|reply
[1]:http://wpcurve.com/slack-integrations/
[+] [-] ljk|10 years ago|reply
[+] [-] purephase|10 years ago|reply
[+] [-] Wingman4l7|10 years ago|reply
[+] [-] pavel_lishin|10 years ago|reply
[+] [-] lotyrin|10 years ago|reply
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
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
[+] [-] unknown|10 years ago|reply
[deleted]
[+] [-] flakmonkey|10 years ago|reply
https://github.com/CharlieHess/slack-poker-bot/blob/master/s...
[+] [-] CharlieHess|10 years ago|reply
[+] [-] todd8|10 years ago|reply
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
Deck.getRandomInt(index+1, numberOfCards)
instead of
Deck.getRandomInt(0, numberOfCards)
[+] [-] shultays|10 years ago|reply
[+] [-] julbaxter|10 years ago|reply
[+] [-] hmate9|10 years ago|reply
[+] [-] an4rchy|10 years ago|reply
[+] [-] 0xCMP|10 years ago|reply
[+] [-] bbcbasic|10 years ago|reply
[+] [-] spelunker|10 years ago|reply
Shoot, I'll just do it myself.
[+] [-] gbin|10 years ago|reply
[+] [-] gdubya|10 years ago|reply
[+] [-] a_t48|10 years ago|reply
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.
[+] [-] CharlieHess|10 years ago|reply
[+] [-] AlexSolution|10 years ago|reply
[+] [-] kordless|10 years ago|reply
[+] [-] cpr|10 years ago|reply
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
[+] [-] CharlieHess|10 years ago|reply
[+] [-] 0xCMP|10 years ago|reply
Number guess, blackjack, this, now maybe battleship...
[+] [-] thomasfromcdnjs|10 years ago|reply
[+] [-] jakejake|10 years ago|reply
[+] [-] awinder|10 years ago|reply
[+] [-] kordless|10 years ago|reply
[+] [-] Pwntastic|10 years ago|reply
[+] [-] CharlieHess|10 years ago|reply
[+] [-] binaryblitz|10 years ago|reply
[+] [-] Yhippa|10 years ago|reply
[+] [-] companyhen|10 years ago|reply
[+] [-] kelyvin|10 years ago|reply
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!
[+] [-] bombtrack|10 years ago|reply
https://nodejs.org/download/