There are a few poker nodes already, under CUFP (apparently the second guy didn't look it up either. :) )... I've left this node as is, but if it gets reaped, that's fine. Sorry about that.

Back to poker odds again...

In Texas Holdem Poker games, you're dealt a pocket of two cards, that only you can see. At this point there's a round of betting, then three communal cards (flop) come down, then betting, then a fourth (turn), then betting, then a fifth (river).

It's necessary to be able to predict the odds of you making your hand in order to determine how to bet.

If, after the flop, you're looking for a single card to fill a straight on either side of your current hand (i.e. you have a 5-6-7-8 and are looking for a 9 or 4) (this is called an "open straight"), you have 8 outs (four 9's and four 4's), and you have roughly a 31.5% chance of getting that by the river (or a 17.4% chance of hitting it on the river, if you missed it on the turn).

These figures are presented by the program, and contain outs all the way up to 46 cards, even though I don't think it's possible to have outs that high. :)

I realize that I didn't use any of the cool perl features for making these types of forms (perl's original task?). It kinda sucks, but I don't plan on making this type of output too often...

kutsu pointed out the node of btrott's, for the rounding function. (Based on the fact that this is at least the third post on the same topic, I think it means that I used someone else's wheels, but I reinvented the automobile. :)) dragonchild Pointed out that you can't use the same odds for texas and omaha (ouch!).

#!/usr/bin/perl -w use strict; #statics my $file = 'outodds.txt'; my $width = 80; my $title = "Texas Holdem Odds From Outs"; my $rowdesk = "Outs\tTurn\t\tRiver\t\tEither\n"; #length calcs my $div = '-' x $width . "\n"; my $widthdif = int($width / 2) - int(length($title)/2); #make top section of report my $top = ' ' x $widthdif . $title . "\n"; $top .= ' ' x $widthdif . '-' x length($title) . "\n\n"; $top .= $rowdesk . $div; #make body my @body; for (1 .. 46) { my $row = "$_\t"; #turn my $perc = $_ / 47; $row .= round($perc * 100, 1) . "%\t\t"; #river $perc = $_ / 46; $row .= round($perc * 100, 1) . "%\t\t"; #either $perc = 1 - (47 - $_) * (46 - $_) / (47 * 46); $row .= round($perc * 100, 1) . "%\n"; push @body, $row; } #print output to file open FILE, ">$file" or die; print FILE $top; print FILE @body; close FILE; sub round { #from perlmonks: http://www.perlmonks.org/index.pl?node_id=8786 #I editted to right-justify for percentages rounded one place sprintf "%5.$_[1]f", $_[0]; }

Output:

                    Texas Holdem Poker Odds From Outs
                    ---------------------------------

Outs	Turn		River		Either
--------------------------------------------------------------------------------
1	  2.1%		  2.2%		  4.3%
2	  4.3%		  4.3%		  8.4%
3	  6.4%		  6.5%		 12.5%
4	  8.5%		  8.7%		 16.5%
5	 10.6%		 10.9%		 20.4%
6	 12.8%		 13.0%		 24.1%
7	 14.9%		 15.2%		 27.8%
8	 17.0%		 17.4%		 31.5%
9	 19.1%		 19.6%		 35.0%
10	 21.3%		 21.7%		 38.4%
11	 23.4%		 23.9%		 41.7%
12	 25.5%		 26.1%		 45.0%
13	 27.7%		 28.3%		 48.1%
14	 29.8%		 30.4%		 51.2%
15	 31.9%		 32.6%		 54.1%
16	 34.0%		 34.8%		 57.0%
17	 36.2%		 37.0%		 59.8%
18	 38.3%		 39.1%		 62.4%
19	 40.4%		 41.3%		 65.0%
20	 42.6%		 43.5%		 67.5%
21	 44.7%		 45.7%		 69.9%
22	 46.8%		 47.8%		 72.2%
23	 48.9%		 50.0%		 74.5%
24	 51.1%		 52.2%		 76.6%
25	 53.2%		 54.3%		 78.6%
26	 55.3%		 56.5%		 80.6%
27	 57.4%		 58.7%		 82.4%
28	 59.6%		 60.9%		 84.2%
29	 61.7%		 63.0%		 85.8%
30	 63.8%		 65.2%		 87.4%
31	 66.0%		 67.4%		 88.9%
32	 68.1%		 69.6%		 90.3%
33	 70.2%		 71.7%		 91.6%
34	 72.3%		 73.9%		 92.8%
35	 74.5%		 76.1%		 93.9%
36	 76.6%		 78.3%		 94.9%
37	 78.7%		 80.4%		 95.8%
38	 80.9%		 82.6%		 96.7%
39	 83.0%		 84.8%		 97.4%
40	 85.1%		 87.0%		 98.1%
41	 87.2%		 89.1%		 98.6%
42	 89.4%		 91.3%		 99.1%
43	 91.5%		 93.5%		 99.4%
44	 93.6%		 95.7%		 99.7%
45	 95.7%		 97.8%		 99.9%
46	 97.9%		100.0%		100.0%

In reply to Poker Odds for Texas Holdem by David Caughell

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.