Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Gambling for Rubyists

Gambling for Rubyists

If baseball is America's Pastime, then surely poker is America's Game. From Rounders to Celebrity Poker, Kenny Rogers to World Series of Poker events on constant loop on ESPN, poker is everywhere in our popular culture. An iconic game of the Wild West, today it has lost much of its stigma and emerged as a preeminent game of skill and intellect dominated by mathematicians, stock brokers, and developers. What has software development brought to this American tradition, and what lessons does poker have to offer us in return? What can we learn from another field? In this talk, I'll give you a crash course in poker, discuss statistics and odds, the psychological aspects of the game, and the business side of managing a career as a professional gambler. You'll come to see that it's not that different from being a developer. After all, its not just poker that could be called 'the hardest way to make an easy buck known to man.'

Kerri Miller

October 22, 2013
Tweet

More Decks by Kerri Miller

Other Decks in Programming

Transcript

  1. GAMBLING FOR RUBYISTS 1 Wednesday, October 23, 13 Good morning,

    my name is Kerri Miller, and I’m a rubyist currently based in Seattle. I have to tell you that I’m still stuck on Japandroids.. check them out.
  2. Preflop 2 Wednesday, October 23, 13 I work for NIRD..

    one of the sponsors.. no no, thank YOU! I’m also one of the lead instructors at Ada Developer’s Academy.. *hand raising* I love getting questions, and don’t mind a little heckling - I’ll give everyone who has a question for me a prize!!
  3. ...for Dummies 3 Wednesday, October 23, 13 First, a disclaimer.

    This is a most basic overview of gambling, statistics, and game theory. I'm using in general lay terms and simplified concepts to explain the basic ideas here - if you're an expert at this stuff or have a quibble, I want to talk to you afterwards.. but please bear with me. I'm not going to say Bayesian probability.
  4. 4 Wednesday, October 23, 13 Second, a disclaimer. Playing poker

    online, and gambling outside of states or jurisdictions where it is legal, or engaging in bookmaking - HIGHLY ILLEGAL. DO NOT DO IT. ...and yes, your March Madness NCAA pool? Outside 2 or 3 states, its illegal as hell.
  5. 5 Wednesday, October 23, 13 Third, a disclaimer. Gambling Addiction

    is a real thing. It ruins a ton of lives. If you or someone you know struggle with gambling, I strongly urge you to seek help. Seriously. Don't wait until you're in trouble. I've won a ton of money from people we sneeringly referred to as "money haters" and its serious.
  6. 6 Wednesday, October 23, 13 I've always been a player

    of games - board, card, role playing. I grew up playing VERY competitive games of pitch, cribbage, monopoly, scrabble with my family, and I picked up poker a friend who had played as a professional before he got a gig at Google. I started playing in early 2003, right before this guy
  7. 7 Wednesday, October 23, 13 Chris Moneymaker (yeah, that's his

    real name) won the World Series of Poker main event, after winning a place in the tournament for $33. Poker was getting hot, and I found I had a natural talent for it. Winning was easy. A few years later, I was burned out on development, and decided to pursue it full time. I was successful enoug.. I didn't get rich, not by any stretch of the imagination, but I made enough to keep traveling, to keep playing, and eventually come to find out that being a software engineer was really what I wanted to spend my time being.
  8. 8 Wednesday, October 23, 13 “The lottery is a tax

    on people who can’t do math” You've probably heard this saying.. yes? Well, its true - if you're playing a game where the outcome is determined by chance, you can never win. The trick is this - not everything is a coin flip. Its all about finding an edge, and aggressively taking advantage of it over and over and over again.
  9. 12 Wednesday, October 23, 13 This is how casinos operate

    - hundreds upon thousands of coinflips where they have a slight edge in the results. The longer you play, the more likely it will be that the casino comes out ahead. Which leads me to share with you my system for beating blackjack. I’ve done all the research, and this is an absolute foolproof plan. Kerri’s Guide to Winning Blackjack - Step #1
  10. DON’T PLAY 13 Wednesday, October 23, 13 + I mean,

    c'mon, its a game where you can get banned from the casino just for being smart (counting cards) + mathematically speaking, you can not "beat" roulette, baccarat, blackjack, or craps. You can play 100% optimally to minimize the edge that the casino has, but you will never get to break even, let alone a winning edge.
  11. The Flop 14 Wednesday, October 23, 13 So its all

    entertainment, right? Its all rigged, right? The casino's hand is always on the scales, right? Turns out, there's 2 places where the casino's interest is in simply getting you to play, not in whether you win or lose. Sports betting, and poker. Sports betting is a topic broad enough for an entirely different talk, so I’m going to focus on poker. So what are the basic rules?
  12. 15 Wednesday, October 23, 13 Each player is dealt 2

    cards face down, and a round of betting occurs.
  13. 16 Wednesday, October 23, 13 After the first round of

    betting has been settled, the dealer reveals the first 3 cards of the hand, called the flop. These cards are played face up in the middle of the table Each player now has 2 cards in their personal hand and 3 community cards
  14. 17 Wednesday, October 23, 13 After the second round of

    betting, the dealer reveals the 4th card of the hand, called the turn, and we have a third round of betting.
  15. 18 Wednesday, October 23, 13 After the third round of

    betting, the dealer reveals the 5th and final card of the hand, called “the river”. Players bet on their hands, and the winner takes the pot... and the casino takes a few bucks -- this is how they make money off the poker room.. well, that and drinks. That’s the basic game, a “hello world” if you will. So how do you know when you've got a winner? When you should bet or fold? How do you find an edge? - you do that with some advice from this guy:
  16. "THE MOST VALUABLE COMMODITY I KNOW OF IS INFORMATION." 19

    Wednesday, October 23, 13 Gamblers never take a bet without an edge (real or perceived.) Information, and the ability to gather it, is gold.
  17. 20 Wednesday, October 23, 13 Unlike a game of chess

    or Go, poker is a game of Incomplete information. In chess or Go, you can see the position of every piece, but in poker, all I can see is whatever cards are visible - the community cards - and how you bet. Do you check? Raise? fumble your chips? Make a speech (AKA "hollywooding")? Poker as a game, is really a conversation about incomplete information, a dance between the players, all trying to find each other inside this fog of uncertainty. Each bet, raise, or call, every new card exposed is a piece of information that refines our understanding of the situation. Operating in a world of incomplete information is exactly the situation that Agile attempts to deal with. We can't know all the variables to begin with, we can only make our best guesses about the over all trajectory or flight path of the project. In the doing of the thing, we will continue to improve the quality of our information, and we'll adjust. But be warned -- anytime someone says they have a system, look closely at it before believing them. TDD, BDD, Agile, Service Oriented Architecture, DCI.. the list goes on and on. Yes, they're good ideas, yes they can solve problems, but take a critical look at these miracle cures before you blindly accept that they'll make everything rainbows and sparkles. Back to gambling.. so, if “it all depends”, then is there anything we can definitively say?
  18. “Every time you play a hand differently from the way

    you would have played it if you could see all your opponents' cards, they gain; and every time you play your hand the same way you would have played it if you could see all their cards, they lose.” 21 Wednesday, October 23, 13 Sklansky's Fundamental Theorem of Poker The Theorem posits that the person who can + gather more information about the situation + who can induce their opponent to make incorrect plays ...will win the most $. Again, it all comes back to information. There is no solution for poker, in that there is no unexploitable strategy for winning. There are /more/ optimal strategies, however. We adjust our own strategy to take advantage of our opponent's deviation from that optimal path, but our adjustments are themselves openings for our opponent to attack.This is what makes poker impossible to AI, but also what makes it beautiful. Code is compromise. Every commit is a decision, that one approach, technology, architecture is better than another. We pick Postgres over, say, Couch, or jRuby over Ruby 2.0, or Sidekiq over Resque, because we feel that we’re gaining a benefit.. and maybe we are, but we’re also incurring a weakness. There are no perfect solutions, only choices. We have to believe that, given our current information, we are making the least incorrect choice of the moment.. and we have to extend that empathy to others when we evaluate their choices. Technical debt is a kind of arbitrage, since its a bet that you have enough information about the future to know that the benefits of your compromises will outweigh the eventual cost of fixing the consequences back to poker.. So we navigate this uncertainty by applying a variety of techniques, to logically understand the value of a hand.
  19. • Hand Selection • Aggression • Position Keys To Winning

    22 Wednesday, October 23, 13 We start by understanding the value of different pairs of starting cards, and how it changes based on whether we act before or after other players. We focus on being aggressive in order to control momentum and subtle, interpersonal perceptions of each other. We recognize and attack weaknesses our opponents display. If you did just this, you’ll be a winner - play good cards, play them hard, and don’t play with players better than you.. Its easy -- but this is just the beginning. Its always easy to be a beginner, when you have knowledge that allows you to be relatively successful on a consistent basis. However the game, like the tech world, is constantly changing. Today’s winning tactics are tomorrow’s dinosaur, so you have to extend your ability to perceive and react to the changing landscape.
  20. • Hand Selection • Aggression • Position • Bet Sizing

    • Pot Odds • Implied Odds • Reverse Implied Odds Keys To Winning 23 Wednesday, October 23, 13 We learn to optimize the amounts we bet, depending on the situation, in order to maximizes our profit, what amounts will induce our opponent to respond in the manner we want them to, and understand the value of a bet in relation to what we're likely to win.. or likely to lose, based on the odds of the next card strengthening or weakening our hands.
  21. • Hand Selection • Aggression • Position • Bet Sizing

    • Pot Odds • Implied Odds • Reverse Implied Odds • Hand Reading • Polarized Ranges • Merged Ranges Keys To Winning 24 Wednesday, October 23, 13 We add more skills to the mix, trying to reduce the number of unknown variables. In poker, we try to put our opponent on a range of potential hands, based on our prior observations of their play style, how much they're betting, how they behave. You have to also think to the level of "what does my opponent think I have" and "what does my opponent think I think they have" Princess Bride double-think. Its a rabbit hole, and you can out-think yourself here by going further down the path than your opponent. You want always to stay one level of thinking ahead of them ..but even when you hone your ability to “soul read” someone, and understand their motivations and responses, they’ll surprise you, so...
  22. • Hand Selection • Aggression • Position • Bet Sizing

    • Pot Odds • Implied Odds • Reverse Implied Odds • Hand Reading • Polarized Ranges • Merged Ranges • Plan B • Plan C • Plan D • Plan O (Shit) Keys To Winning 25 Wednesday, October 23, 13 you need to have contingencies. If I raise and she shoves all-in, whats my play? What if I bet a small amount, hoping he raises, but instead he just meekly calls my bet? What then? This is a ton of things to keep track of.. in some ways, it reminds me of Rails - a big pile of sometimes conflicting ideas, that somehow all gels together and works. So, with all these different threads running in parallel with each other - plus another dozen I’m not mentioning here, does it make a little more sense why poker players, when asked for advice on how to play, say this:
  23. “It Depends.” -- every poker player ever 26 Wednesday, October

    23, 13 In poker the stock answer, anytime someone asks for your opinion about how they should've played a particular hand is "It Depends" Its a mantra, an inside joke, and an honest statement of fact. In the words of the great poet:
  24. “Now every gambler knows that the secret to survivin' Is

    knowin' what to throw away and knowin’ what to keep. 'Cause every hand's a winner and every hand's a loser..." 27 Wednesday, October 23, 13 every hand's a winner and every hand's a loser (c’mon, you can’t talk about poker without a Kenny reference) Context is EXTREMELY important. Without it, there's no way to understand whether a decision is correct or not. In poker, there are hands that are generally considered to be a marginal value at best, however in the right situation, they become powerhouse generators of profit. While others might discard the hand, if you recognize that the value of any hand is HIGHLY dependent upon the situation, to factors external to the cards themselves, you stand to profit. So how do you do it? How do you know, given imperfect information, when you’re holding a winner? Well, you could figure the odds by using brute force, but
  25. BRUTE FORCE? •2,097,572,400 pre-flop hand match ups to calculate •~5

    minutes in 1.9.3 •Even after the flop, 1,070,190 combinations 28 Wednesday, October 23, 13 + when you have 2 cards in your hand, there are 2,097,572,400 hand match ups to calculate + takes ~ 5 minutes in Ruby (!) + now granted, I might have used a bad Big-O algorithm.. Davy, can we talk later? + after the flop, there are a "mere" 1,070,190 (.25 seconds) + memorize the odds of common situations
  26. LAW OF 4 & 2 •Count “outs” (cards that improve

    your hand) •To find the percentage chance of improving your hand: •On the flop, multiply by 4 •On the turn, multiply by 2 29 Wednesday, October 23, 13 + heuristics + Phil Gordon - law of 4 and 2 > "In Phil Gordon's Little Green Book (a very good book I might add) he describes a very simple heuristic that can be calculate in your head that give the approximate odds of hitting your "outs". He calls this "the rule of 4 and 2". The way this heuristic works is that you count your outs. If you've just seen the flop (and not the turn card) then multiply the outs by 4 and you will have the approximate percentage of hitting your outs. If you've seen the turn (but not the river) you multiply the outs by 2 to get the approximate odds of hitting your outs."
  27. 31 Wednesday, October 23, 13 Early on in my poker

    career, I was watching a friend play poker online. He was playing pretty sizeable stakes, and at one point lost a 4-digit sum that was more than the rent on my house in Seattle to a lucky card. "Its ok," he said with a shrug, "I usually win there." This turns out to be one of the important themes of poker
  28. EXPECTED VALUE 32 Wednesday, October 23, 13 Expected Value, or

    "EV", is the idea that if we continue to make correct decisions, over and over again, we will eventually come out ahead, no matter how we fare in a specific situation. In software, we write tests, not because we've ever come up with any kind of meaningful metric for understanding the value of a single test, but because as a whole, as a gestalt, we expect to produce better code in the long run. That net effect - software guided by tests, managed by tests, and confirmed by tests being objectively better - is what drives us towards TDD.
  29. 33 Wednesday, October 23, 13 This is Eddie Gaedel, the

    shortest baseball player ever. He had one at bat, on August 19th, 1951, as a publicity stunt. He was walked on 4 consecutive pitches, and replaced with a pinch runner. So.. statistically speaking, he has an on-base percentage of 1.000. According to numbers, he will ALWAYS get on base. Right?
  30. 34 Wednesday, October 23, 13 Poker taught me the value

    of not being results oriented. If you make a play, and you lose, instinct tells you to assume that particular play is bad - touch a stove and get burned, you stay away from stoves, right? When you can pull your thinking back up to the level of considering the process by which you arrived at a decision, and evaluate the assumptions outside the results, you can begin to establish control over the EV of a given decision. Thinking that the result of one or two trials is indicative of the merits of the process is why we hear this
  31. “I TRIED TDD, AND IT WAS SLOW, USELESS, SUCKY, AND

    A WASTE OF TIME.” 35 Wednesday, October 23, 13 We hear this all the time, don't we? You can replace TDD with anything - Kanban, Agile, Continuous Integration, SOLID... “Oh, you tried something once, it didn’t work out, and now you KNOW its a worthless tool or process? “
  32. 37 Wednesday, October 23, 13 Not just for pinball machines!

    Poker also taught me the value of emotional self control. Its an ongoing lesson, naturally, as I /am/ a Scorpio and I /am/ a red-head. When one loses self-control, you "go on tilt" I've seen people spew money after a particularly bad turn of the cards, or unfair ruling in their opponents favor. They lose all rationality and distance, shoving money into the pot as if they had an allergy to the stuff. At times, poker seems designed to make you give in to rage and frustration.. its like software development that way.. To get good at poker, you have to learn to deal with your internal struggle with the inherent unfairness of it. You have to learn patience, to accept the long-view of expected value, that you will experience runs of bad luck as well as good, and you can't always win. Even when you're, say, a 15-to-1 favorite to win a hand, sometimes you're going to lose. Focusing instead on the process, rather than the results, is crucial. This is a lesson that every poker play struggles with.
  33. 38 Wednesday, October 23, 13 We all fall in love

    with things. I have a sick, sick love of queen-duece suited.. I will play that hand as if its pocket aces.. maybe I should, maybe I shouldn't, but its the irrationality of my doing so that is the problem. Similarly, we all have techniques or practices in our coding that we love, but aren't particularly productive. Maybe its a favorite tool that just slows us down, or gem that's really outdated and buggy.. but its something that limits our thinking, our ability to innovate. Its an albatross, a millstone around our neck that needs to be cast aside. Find YOUR queen-deuce and kill it dead. Poker players refer to these sub-optimal plays as “leaks” - as if we’re literally leaking money out.. We find these leaks in our game by
  34. 39 Wednesday, October 23, 13 being obsessive about metrics.. especially

    if you play online, where you can play as many as 24 tables of poker at once. You'll be seeing hundreds of hands per hour, meaning you've ample opportunity to flip that coin again and again. Between than and the widely available tools, its trivial to assemble a database of millions of hands of poker, which allows you to analyze EVERY situation to the Nth degree in order to find every spec of profit... and I do mean EVERY situation.
  35. 40 Wednesday, October 23, 13 We have these tools as

    well, with similarly broad data sets and standards to evaluate our code in order to improve our abilities. Use them. Why?
  36. 41 Wednesday, October 23, 13 No one is as good

    as they think they are. But by tracking our progress, using metrics to understand success and where we should prioritize our efforts to improve, we can guarantee an upward trajectory in our skill and overall "success".
  37. + 42 Wednesday, October 23, 13 To be successful, you

    have to do this peculiar trick in your brain. You have to have an aggressive belief in your own abilities, that are capable of anything at the table. So while you do this, you also have to obsessively self-analyze your play - did I bet enough in this spot, or too much here? What mistakes did I make? How could I have played better? You have to believe that you can do anything, but also the honesty to admit failure, the self- confidence to question yourself and the assumptions you make.
  38. 43 Wednesday, October 23, 13 “The key to the game

    is playing the player, not the cards.” Its true - every decision is made within the context of the person you're playing against. In software, we too often forget the people portion of the job. We forget that code is written for humans, and only incidentally written for computers. We forget that there are real live people using our code, and how they think and how they /feel/ matters. The most successful poker players are also the one with the strongest social skills and empathy. This is also true of every great developer I’ve met. Empathy and socials skills are learnable - don’t believe the hype that you simply /can’t/ talk to people because you’re a nerd, so why even try. It might not be easy, but its invaluable to learn.
  39. The River 44 Wednesday, October 23, 13 Frank Lantz, director

    of NYU’s Game Center, and an exec at Zynga, gave a talk at a recent GDC, about the games of poker and Go. He talked at length about how poker trains you to see your opponent's hand as a smear of possibilities
  40. 45 Wednesday, October 23, 13 + you begin to see

    the world as a series of overlapping probabilities fields + face to face with bayesian logic (the logic of science) When everything becomes a possibility, we survive not by sorting possible from impossible, but by honing our ability to identify what is the probable and improbable, moving from evidence through uncertainty to arrive at knowledge. Part of the beauty is watching your own mind wrap around the problem, as our brains step through the discipline of applying logic to the imperfect knowledge of the situation at hand. We become one with the act of discovery. The simple act of looking for leaks in our game, ways in which we are vulnerable, becomes an exploration of leaks in our personality. Lantz spoke also about the tradition of Go as a martial art, and considered poker (and by extention, all gaming) as the same. He proposed a modernized set of rules for studying the game, based on some traditions of the martial arts.
  41. • Poker as an established discipline • Approach the game

    with humility • Don't just play, enter the the game as if entering a sacred space • Practice the game as a form of moving meditation • Respect the game, opponents, and yourself • Embrace proper techniques, customs, and rituals without question • Breathe 46 Wednesday, October 23, 13 ..and interestingly enough, these are very much the emergent practices of the poker community. Much as the discipline learned in a martial art ideally transcend the dojo and enter one’s day-to-day life, so to do these rules expand to fill your life outside the game. Soon, everything becomes a calculation of motivation and expected value, of desire and leaks and edges.. but not in some zero- sum game against the world, but in a positive-sum game with yourself. What’s interesting is that you can apply these same rules to development
  42. • Code as an established discipline • Approach the code

    with humility • Don't just program, enter the the code as if entering a sacred space • Practice the code as a form of moving meditation • Respect the code, opponents, and yourself • Embrace proper techniques, customs, and rituals without question • Breathe 47 Wednesday, October 23, 13 Because why can't software development be a martial art? When I returned to development from playing poker, I found myself applying this sort of approach to development, and I discovered that I wasn’t burned out on development after all, but in my approach to it.
  43. 48 Wednesday, October 23, 13 Ultimately, poker, like so many

    careers and hobbies I’ve partaken in, has brought me pleasure in the simple act of learning and thinking about it and walking a path towards perfecting it. Its tough sometimes to see the connection between simple techniques and ideas and the mastery of a skill. We are taught to get ahead by working hard.. but the more I looked at the careers and hobbies I’ve had, this pattern emerged - you don’t learn anything by working harder at poker, glass working, programming.. Success follows working hard /away/ from the work itself, by being dedicated to learning, focusing on fundamentals, a fearless attitude towards exploration, and understanding failures (and successes) as opportunities to examine our work.. and ourselves. Having a pursuit outside of technology is super important, because it enables you to meet people outside your normal day-to- day world, see how other communities solve problems, how they approach their own craft, exposing yourself to a wider diversity of people and thoughts. Nurturing those hobbies and pastimes that you have, and you will be rewarded with fresh perspectives on your software career, stretching your mind, increasing your empathy and social skills.. the list of the benefits from being a well-rounded, eclectic person goes on and on. They say that poker is “a hard way to make an easy buck” - isn’t that true of software developer? of being a freelancer? Isn’t that true of everything?
  44. ★ glass artist ★ Vespa mechanic ★ lighting designer ★

    author & teacher ★ player of games ★ software developer @kerrizor KERRI MILLER 49 Wednesday, October 23, 13