{"id":5086,"date":"2014-01-10T09:00:43","date_gmt":"2014-01-10T14:00:43","guid":{"rendered":"https:\/\/blogs.mathworks.com\/pick\/?p=5086"},"modified":"2014-03-03T14:17:54","modified_gmt":"2014-03-03T19:17:54","slug":"poker-analyzer","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/pick\/2014\/01\/10\/poker-analyzer\/","title":{"rendered":"Poker Analyzer"},"content":{"rendered":"\r\n<div class=\"content\"><p><a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/29096\">Idin<\/a>'s pick for this week is <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/6710-texas-hold-em-poker-analyzer\">Texas Hold'Em Poker Analyzer<\/a> by <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/83521\">Tim Farajian<\/a>.<\/p><p>I have always been fascinated by games of chance. As an undergrad, I took some courses in probability and statistics. The more I learned about theory of probability, my fascination with card games in particular grew. Blackjack is my favorite casino game because the rules are very simple, and it can be analyzed through pure statistics (unlike poker where other players' actions are a significant part of the game).<\/p><p>For this week, I wanted to find a nice example of a card game in MATLAB, preferably one with some automated simulation built-in. I started with blackjack. <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/4958\">Cleve Moler<\/a>'s <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/4404-blackjack\">Blackjack<\/a> game is an example of an elegant MATLAB program, and how blackjack strategy can be implemented using simple matrices in MATLAB. He has an article on the subject <a href=\"https:\/\/www.mathworks.com\/company\/newsletters\/articles\/simulating-blackjack-with-matlab.html\">here<\/a>. But the simulation is not automated. <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/30437\">Michael Iori<\/a>'s <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/18688-blackjack\">Blackjack<\/a> came close, but wasn't as feature-rich as my eventual pick.<\/p><p>I finally went to poker, and came across Tim Farajian's <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/6710-texas-hold-em-poker-analyzer\">Texas Hold'Em Poker Analyzer<\/a>. This is an elaborate app with nice graphics that allows a user to simulate different scenarios in a Texas Hold'Em game. The interface is very simple and intuitive. Best of all, it automatically simulates as many hands as I would like, and displays winning probabilities or expected returns. No longer do I have to wonder if 8-10 suited is better than a pair of 3s; I can simply simulate and find out (slight edge goes to 8-10 suited, as seen below!).<\/p><p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/idin\/potw_poker\/PokerScreenShot2.png\" alt=\"\"> <\/p><p>Tim's example is useful on multiple fronts other than answering my poker questions! It's a nice example of MATLAB apps; he uses simple commands to draw the board and cards. He also implements the game itself efficiently (it's not trivial to deal out cards, or to analyze poker hands and rank them!). The program simulates thousands of hands in mere seconds. I also like its potential to serve as a blueprint for simulators of other games (e.g., blackjack!). A combination of Tim's graphics with Cleve Moler's blackjack could yield a nice blackjack analyzer. There are also some possibilities for improvements of the poker game, such as allowing a range of hands for a given player rather than specific cards (in a real poker game, you might know that a player has a strong hand, but not know his exact cards).<\/p><p>As always, your thoughts and comments <a href=\"https:\/\/blogs.mathworks.com\/pick\/?p=5086#respond\">here<\/a> are greatly appreciated.<\/p><script language=\"JavaScript\"> <!-- \r\n    function grabCode_9c82a65523214db4b269c9c73af9208e() {\r\n        \/\/ Remember the title so we can use it in the new page\r\n        title = document.title;\r\n\r\n        \/\/ Break up these strings so that their presence\r\n        \/\/ in the Javascript doesn't mess up the search for\r\n        \/\/ the MATLAB code.\r\n        t1='9c82a65523214db4b269c9c73af9208e ' + '##### ' + 'SOURCE BEGIN' + ' #####';\r\n        t2='##### ' + 'SOURCE END' + ' #####' + ' 9c82a65523214db4b269c9c73af9208e';\r\n    \r\n        b=document.getElementsByTagName('body')[0];\r\n        i1=b.innerHTML.indexOf(t1)+t1.length;\r\n        i2=b.innerHTML.indexOf(t2);\r\n \r\n        code_string = b.innerHTML.substring(i1, i2);\r\n        code_string = code_string.replace(\/REPLACE_WITH_DASH_DASH\/g,'--');\r\n\r\n        \/\/ Use \/x3C\/g instead of the less-than character to avoid errors \r\n        \/\/ in the XML parser.\r\n        \/\/ Use '\\x26#60;' instead of '<' so that the XML parser\r\n        \/\/ doesn't go ahead and substitute the less-than character. \r\n        code_string = code_string.replace(\/\\x3C\/g, '\\x26#60;');\r\n\r\n        copyright = 'Copyright 2014 The MathWorks, Inc.';\r\n\r\n        w = window.open();\r\n        d = w.document;\r\n        d.write('<pre>\\n');\r\n        d.write(code_string);\r\n\r\n        \/\/ Add copyright line at the bottom if specified.\r\n        if (copyright.length > 0) {\r\n            d.writeln('');\r\n            d.writeln('%%');\r\n            if (copyright.length > 0) {\r\n                d.writeln('% _' + copyright + '_');\r\n            }\r\n        }\r\n\r\n        d.write('<\/pre>\\n');\r\n\r\n        d.title = title + ' (MATLAB code)';\r\n        d.close();\r\n    }   \r\n     --> <\/script><p style=\"text-align: right; font-size: xx-small; font-weight:lighter;   font-style: italic; color: gray\"><br><a href=\"javascript:grabCode_9c82a65523214db4b269c9c73af9208e()\"><span style=\"font-size: x-small;        font-style: italic;\">Get \r\n      the MATLAB code <noscript>(requires JavaScript)<\/noscript><\/span><\/a><br><br>\r\n      Published with MATLAB&reg; R2013b<br><\/p><p class=\"footer\"><br>\r\n      Published with MATLAB&reg; R2013b<br><\/p><\/div><!--\r\n9c82a65523214db4b269c9c73af9208e ##### SOURCE BEGIN #####\r\n%%\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/29096\r\n% Idin>'s pick for this week is\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/6710-texas-hold-em-poker-analyzer Texas Hold'Em\r\n% Poker Analyzer> by\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/83521 Tim\r\n% Farajian>.\r\n%\r\n% I have always been fascinated by games of chance. As an undergrad, I took\r\n% some courses in probability and statistics. The more I learned about\r\n% theory of probability, my fascination with card games in particular grew.\r\n% Blackjack is my favorite casino game because the rules are very simple,\r\n% and it can be analyzed through pure statistics (unlike poker where other\r\n% players' actions are a significant part of the game).\r\n%\r\n% For this week, I wanted to find a nice example of a card game in MATLAB,\r\n% preferably one with some automated simulation built-in. I started with\r\n% blackjack.\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/4958 Cleve\r\n% Moler>'s <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/4404-blackjack\r\n% Blackjack> game is an example of an elegant MATLAB program, and how\r\n% blackjack strategy can be implemented using simple matrices in MATLAB. He\r\n% has an article on the subject\r\n% <https:\/\/www.mathworks.com\/company\/newsletters\/articles\/simulating-blackjack-with-matlab.html\r\n% here>. But the simulation is not automated.\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/30437\r\n% Michael Iori>'s\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/18688-blackjack\r\n% Blackjack> came close, but wasn't as feature-rich as my eventual pick.\r\n%\r\n% I finally went to poker, and came across Tim Farajian's\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/6710-texas-hold-em-poker-analyzer Texas Hold'Em\r\n% Poker Analyzer>. This is an elaborate app with nice graphics that allows\r\n% a user to simulate different scenarios in a Texas Hold?Em game. The\r\n% interface is very simple and intuitive. Best of all, it automatically\r\n% simulates as many hands as I would like, and displays winning\r\n% probabilities or expected returns. No longer do I have to wonder if 8-10\r\n% suited is better than a pair of 3s; I can simply simulate and find out\r\n% (slight edge goes to 8-10 suited, as seen below!).\r\n%\r\n% <<PokerScreenShot2.png>>\r\n%\r\n% Tim's example is useful on multiple fronts other than answering my poker\r\n% questions! It's a nice example of MATLAB apps; he uses simple commands to\r\n% draw the board and cards. He also implements the game itself efficiently\r\n% (it's not trivial to deal out cards, or to analyze poker hands and rank\r\n% them!). The program simulates thousands of hands in mere seconds. I\r\n% also like its potential to serve as a blueprint for simulators of other\r\n% games (e.g., blackjack!). A combination of Tim's graphics with Cleve\r\n% Moler's blackjack could yield a nice blackjack analyzer. There are also\r\n% some possibilities for improvements of the poker game, such as allowing a\r\n% range of hands for a given player rather than specific cards (in a real\r\n% poker game, you might know that a player has a strong hand, but not know\r\n% his exact cards).\r\n%\r\n% As always, your thoughts and comments\r\n% <https:\/\/blogs.mathworks.com\/pick\/?p=5086#respond here> are greatly\r\n% appreciated.\r\n##### SOURCE END ##### 9c82a65523214db4b269c9c73af9208e\r\n-->","protected":false},"excerpt":{"rendered":"<div class=\"overview-image\"><img decoding=\"async\"  class=\"img-responsive\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/idin\/potw_poker\/PokerScreenShot2.png\" onError=\"this.style.display ='none';\" \/><\/div><p>\r\nIdin's pick for this week is Texas Hold'Em Poker Analyzer by Tim Farajian.I have always been fascinated by games of chance. As an undergrad, I took some courses in probability and statistics. The... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/pick\/2014\/01\/10\/poker-analyzer\/\">read more >><\/a><\/p>","protected":false},"author":36,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[16],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/5086"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/users\/36"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/comments?post=5086"}],"version-history":[{"count":7,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/5086\/revisions"}],"predecessor-version":[{"id":5092,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/5086\/revisions\/5092"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/media?parent=5086"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/categories?post=5086"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/tags?post=5086"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}