Hacker News new | past | comments | ask | show | jobs | submit login
Slack Poker Bot (github.com/charliehess)
318 points by CharlieHess on Sept 1, 2015 | hide | past | favorite | 96 comments



Feature request: zenpayroll integration


feature request: turbo tax shelter.


This[1] page shows that it already exists?

[1]:http://wpcurve.com/slack-integrations/


is there a way to spin it so it'll be legal in the US?


It varies by state, but home poker games often aren't expressly illegal. The illegal aspect is often profiting off of running the poker game. As long as you don't implement a rake into the system and you are paying out the entire pot, you are probably good from a legal perspective although IANAL.


When I played poker at MSFT in WA state, another rule was that you couldn't bet truly blind. You had to at least look at your cards. To see your cards and bet was a 'game of skill', to not was 'gambling'.


That's what gives away the tell... I'd say reading people is probably the more relevant skill than counting odds...


No, that's not how poker is played, it really is about counting odds and evaluating the possible plays. Unless you were kidding of course and I'm far to sleepy again.


So you couldn't play a game like Hold 'em that requires a small and big blind? Or anything requiring pre-deal antes?


If you remove the antes in poker, then it is no longer a game of skill.

The only reason to make a bet is because of the antes, otherwise you will only play AA, as should everyone else.


Did you play at Cafe 40/42? =)


At times... I was out at RedWest.


This is the case in California, which will cover many of the people that would use this. As long as there is no rake, the game is legal. If you'd like to see the law in your state, see:

http://www.homepokergames.com/homepokerlaw.php


While not a poker player, I can't help respect the why-the-fuck-not? aspect of this. Very cool.


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.


This has support for both!


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


Are images even necessary, anyway?

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


You can't control the font rendering in Slack (it's Lato, at a certain size). The Unicode cards are far too small to read.


I did think of that. But you could use the symbols for the houses and pair them with a number/letter.


The Slack API only allows a single image URL for attachments. I was also keen on the idea of being able to swap out the card assets whenever. Unicode playing cards is a decent idea, except Slack only renders in Lato.


Does Slack accept images with data URIs instead of URLs? Seems like it'd give you the best of both worlds.


    >  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?


I saw it on HN a while ago- a webservice that does poker hands using a URL; you could pass it cards in the URL and it would display them.


deckofcardsapi.com, if it's the one I'm thinking of?


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...)... ;-)


The [imgur](https://github.com/kaimallea/node-imgur) API lets you upload an image (anonymously) and responds with a URL. I promisify'd that and the result is super straightforward. You don't even need to auth.


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...



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.


Are you talking about the hole cards that are DM'ed to you? That's a good suggestion; feel free to file an issue.


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.


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)


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?


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


Request: Planning poker integration to vote for story point


Request: Battleship for Slack


Yes! Also, this might be a new genre of slack integrations.. games.... :lightbulb:


Just copy the countless IRC game bots :)


I have never used slack. How is it different than IRC?


Just a way better interface on it. Searchable history, multiple rooms inside rooms effectively. File sharing, lots of niceties that are probably possible in IRC but would take a lot of work. It has changed the way our team communicates, for me I am the only remote guy on a team of 6ish devs. I can pick and choose my hours, work when other guys are off, and still see all the comms that happened while I wasn't at my machine.


> I can pick and choose my hours, work when other guys are off, and still see all the comms that happened while I wasn't at my machine.

I'm sure are features IRC cannot duplicate, but all that's necessary for that is a bouncer.


Right. Think of Slack as a really well configured IRC server, except you don't have to manage it at all, and it's front-end UI is much more modern (and better); integrated file uploading, inline media, integrations with everything under the sun, etc. None of it is impossible in IRC, it's just _easier_ in Slack because it's out of the box like that.

And, most importantly: I don't have to manage the damned server ;)


Are there open source/open protocols for something like Slack? Rich IRC?


There are a couple of protocols that do similar things, but nearly all of them have a major fatal flaw, that is unfortunately very difficult to work around through no fault of their own: mobile push notifications, especially on iOS. An open protocol is useful, but not enough, and that's where Slack hosting and developing everything themselves has an advantage, despite open protocols and tools being what I'd normally want to use. But practicality matters, and so when I last looked at alternatives a year ago, I couldn't find anything that would be a drop-in feature-complete replacement. It's a shame, but I expect something to come up in the future, perhaps on Matrix or other protocols.


Matrix has push, at least on Android.


matrix.org is pretty good. Theoretically a well configured XMPP server would do.


Yup, totally to your last line. That is it entirely, all of this stuff is probably possible with a ton of time invested into IRC.

But we have shit to build! :)


True, and I use a bouncer myself, but it's something you have to set up explicitly - Slack already does it for you. Notifications as well - you can get emails, or texts, or the app on your phone can ping you.

And sure, a bouncer with some plugins could do it, but you'd have to set it all up. I've had "have bouncer email me when I'm mentioned in a channel" as a mental to-do for the past five years, and it's never been a high-enough priority for me to sit down and expend the minimum of two hours it would take (and likely much more.)


I love everything about Slack except the damn chat window. Oh, and the pricing. The onboarding process is buttery smooth, and there are tons of integrations. But there's so little in the way of communication density (even in 'compact mode') that I miss IRC.

We have a jira integration set up and every ticket consumes five lines plus plenty of whitespace - a few of those and there's no real comms visible on the page. Every integration I've see consumes gobs of space. Similarly, flagging announcements by assigning a colour is almost worthless - the colour bar isn't very visible (I prefer hipchat's method, where the entire chatline gets the background colour set). Then there's the problem of people's actual chat messages being the least visible thing on the page - smaller and less noticable than names, integration notifications, what have you. But the onboarding is so easy, it just sucks users up.

Being able to see a conversation instead of bells and whistles? I miss that... but plain text scares regular users...


[deleted]


He covered that in his second sentence.

> But there's so little in the way of communication density (even in 'compact mode')


Could you run Slack web in Chrome, and find or make a userstyle that would tighten it up?

https://userstyles.org/styles/browse/slack


I hear those complaints, we found them early on too. We have since separated operational noise in to other channels that ONLY contain integration related stuff, and try to keep one channel purely for actual chatter.


And Slack removed the "daily network split" feature that IRC uses, deciding it was a bad choice going forward.


IRC doesn't have a 3 billion dollar valuation.


Watch, soon we'll see articles about how "Slack built a platform..." and how the next big things are games for slack /s


Or how Slack, like Facebook gets banned at many workplaces.


Feature request! HipChat integration!

Shoot, I'll just do it myself.


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


Because the fun part was writing the game logic, not the glue code. ;)


it was re:the comment, not the OP. I totally understand :)


Hurry up then


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.

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.


Wrote up a workaround until I can fix it properly.


Feature request: bitcoin integration


My thought exactly. But first, I'm containerizing it.


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.


There are unicodes for the cards, e.g. 🂶🃆. Does slack support color text?


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.


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...


This is so good, I got it working in less than a minute. My team is going to have a blast with this.


Cool! Do you have a public server that's running the bot, or do you just run it on your local machine?


You can deploy via Heroku now, thanks to gangstead.


Tested it out in the office. Productivity killed.


Thanks, I'll check that out!


Very cool! Threw together a quick docker image if anyone finds it useful https://hub.docker.com/r/awinder/slack-poker-bot/


I've ported this to run on Giant Swarm: https://github.com/giantswarm/swarm-holdem. That repo also supports running it locally in a container.


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


Does the Heroku deploy work for you?


The Heroku deploy does appear to work, but I was hoping to get it all running locally. Thanks though! It looks like there's a ticket on the lwip project on github that is similar to my issue, so hopefully they'll resolve that soon enough :)


Anyone having an issue with npm doing this: FATAL ERROR: JS Allocation failed - process out of memory


Super awesome! A few buddies and I use TriviaBot. So much fun. Can't wait to install this.


As a new dev: How do I get npm install to run? I'm on step 4 of the instructions.


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!


Figured it out myself! Thanks :)


NPM is the Node Package Manager. So, you must have node installed to get npm.

https://nodejs.org/download/


This is pretty neat. I just hope no one gets in trouble at work playing poker.


Great I was just looking for something to feed to my machine learning thesis.


@Charlie - How do I get in this SF Utes slack channel? :) Go Utes!


Would you be open to a PR adding HipChat support?


Certainly not opposed; it's pretty tightly coupled to the Slack API, though.


Installed 30 minutes ago, entire team hooked


Hoping someone does this with chess, too!


Slack off with some poker!


id love it if i can do this in only private chat lol




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: