{"id":1090,"date":"2011-08-17T08:52:07","date_gmt":"2011-08-17T08:52:07","guid":{"rendered":"http:\/\/www.navision-blog.de\/2011\/08\/17\/some-special-monads-in-f-part-5-of-n-application-poker\/"},"modified":"2011-08-17T10:17:19","modified_gmt":"2011-08-17T10:17:19","slug":"some-special-monads-in-f-part-5-of-n-application-poker","status":"publish","type":"post","link":"http:\/\/www.navision-blog.de\/blog\/2011\/08\/17\/some-special-monads-in-f-part-5-of-n-application-poker\/","title":{"rendered":"Some special monads in F# &#8211; Part 5 of n &#8211; Application: Poker &#8211; Your chance to get rich!"},"content":{"rendered":"<p>In the <a href=\"http:\/\/www.navision-blog.de\/2011\/08\/16\/some-special-monads-in-f-part-4-of-n-application-the-monty-hall-problem\/\">last part of this blog series<\/a> I showed how we can utilize the <a href=\"http:\/\/www.navision-blog.de\/2011\/08\/15\/some-special-monads-in-f-part-3-of-n-distributionmonad\/\">DistributionMonad<\/a> in order to solve the famous <a href=\"http:\/\/en.wikipedia.org\/wiki\/Monty_Hall_problem\">Monty Hall problem<\/a>. This time I want to show you how we can use it to solve some basic <a href=\"http:\/\/en.wikipedia.org\/wiki\/Texas_hold_%27em\">Texas hold\u2019em poker<\/a> questions.<\/p>\n<p>We start by defining a model for poker in F#:<\/p>\n<p> <script src=\"https:\/\/gist.github.com\/1151080.js\"> <\/script>  <\/p>\n<p>As you can see we model cards as tuples of a rank and a suit. The complete deck is just a combination of all ranks with all suits.<\/p>\n<p>Now we need some additional helpers for the DistributionMonad, which will allow us to draw cards from the deck. You can find further explanations about these helpers in the excellent paper by Martin Erwig and Steve Kollmansberger called <a href=\"http:\/\/web.engr.oregonstate.edu\/~erwig\/papers\/PFP_JFP06.pdf\">&quot;Functional Pearls: Probabilistic functional programming in Haskell&quot;<\/a>. Like the DistributionMonad itself, these helpers are already in the <a href=\"https:\/\/github.com\/panesofglass\/FSharp.Monad\">FSharp.Monad<\/a> project and you get the bits from <a href=\"http:\/\/nuget.org\/List\/Packages\/FSharp.Monad\">nuget.org<\/a>.<\/p>\n<p> <script src=\"https:\/\/gist.github.com\/1151079.js\"> <\/script>  <\/p>\n<p>Now we are ready to perform our first query. Let&#8217;s see how we can compute the probability of drawing the Ace of Clubs and the Ace of Spades:<\/p>\n<p> <script src=\"https:\/\/gist.github.com\/1151108.js\"> <\/script>  <\/p>\n<p>But we can easily go a step further:<\/p>\n<p> <script src=\"https:\/\/gist.github.com\/1151121.js\"> <\/script>  <\/p>\n<p>If you keep this model in mind you might come up with a poker odds calculator on a smart phone. This might be your chance to get rich. \ud83d\ude09<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In the last part of this blog series I showed how we can utilize the DistributionMonad in order to solve the famous Monty Hall problem. This time I want to show you how we can use it to solve some basic Texas hold\u2019em poker questions. We start by defining a model for poker in F#: [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[448,8],"tags":[664,582],"_links":{"self":[{"href":"http:\/\/www.navision-blog.de\/blog\/wp-json\/wp\/v2\/posts\/1090"}],"collection":[{"href":"http:\/\/www.navision-blog.de\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.navision-blog.de\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.navision-blog.de\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.navision-blog.de\/blog\/wp-json\/wp\/v2\/comments?post=1090"}],"version-history":[{"count":5,"href":"http:\/\/www.navision-blog.de\/blog\/wp-json\/wp\/v2\/posts\/1090\/revisions"}],"predecessor-version":[{"id":1096,"href":"http:\/\/www.navision-blog.de\/blog\/wp-json\/wp\/v2\/posts\/1090\/revisions\/1096"}],"wp:attachment":[{"href":"http:\/\/www.navision-blog.de\/blog\/wp-json\/wp\/v2\/media?parent=1090"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.navision-blog.de\/blog\/wp-json\/wp\/v2\/categories?post=1090"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.navision-blog.de\/blog\/wp-json\/wp\/v2\/tags?post=1090"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}