Advertisement
Leedwon

NL Hold'em

Jan 16th, 2017
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 53.67 KB | None | 0 0
  1. // No Limit Hold'em alpha version
  2.  
  3.  
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. #include <time.h>
  7. #include <windows.h>
  8.  
  9. const char suits[] = { 'c', 'd', 'h', 's' };
  10. const char rank[] = { '2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A' };
  11. const int  pair=32, twopairs=303, threeOfaKind=430, straight=668, flush=719 , boat=937, quads=996, str8flush=1248;
  12.  
  13. typedef struct
  14. {
  15.     int value;
  16.     int suit;
  17. } card;
  18. typedef struct
  19. {
  20.     int stack1;
  21.     int stack2;
  22.     int pot;
  23.     int decisionOn;
  24.     int bet;
  25. } game;
  26. typedef struct
  27. {
  28.     int hand1;
  29.     int hand2;
  30. } handStrength;
  31. int random(int zakres1, int zakres2)
  32. {
  33.           int value;
  34.           value = rand()%(zakres2-zakres1+1) + zakres1;
  35. return value;
  36. }
  37. void sortowanie(int tab[], int ile_elementow)
  38. {
  39.     int i, j;
  40.     for(i=0;i<ile_elementow;i++)
  41.     {
  42.         for(j=0;j<ile_elementow-1;j++)
  43.         {
  44.             if(tab[j]>tab[j+1])
  45.             {
  46.                 int swap = tab[j];
  47.                 tab[j] = tab[j+1];
  48.                 tab[j+1] = swap;
  49.  
  50.             }
  51.         }
  52.     }
  53. }
  54.  
  55. void sortowanie_kart(card tab[], int ile_kart)
  56. {
  57.     int i,j;
  58.     for(i=0;i<ile_kart;i++ ) // srotowanie reki gracza
  59.      {
  60.         for(j=0;j<ile_kart-1;j++ )
  61.         {
  62.             if(tab[j].value>tab[j+1].value)
  63.             {
  64.                 card swap = tab[j];
  65.                 tab[j] = tab [j+1];
  66.                 tab[j+1] = swap;
  67.             }
  68.         }
  69.     }
  70. }
  71. int checkStr8Flush(card cards[])
  72. {
  73.     int clubs = 0;
  74.     int diamonds = 0;
  75.     int hearts = 0;
  76.     int spades = 0;
  77.     int i, j;
  78.     int value = 0;
  79.     int str8 = 0;
  80.     for(i=0;i<7;i++)
  81.     {
  82.         if(cards[i].suit==0) clubs++;
  83.         else if(cards[i].suit==1) diamonds++;
  84.         else if(cards[i].suit==2) hearts++;
  85.         else if(cards[i].suit==3) spades++;
  86.     }
  87.     int kolor[7]={-1, -1, -1, -1 ,-1 -1, -1};
  88.     if(clubs>=5)
  89.     {
  90.         for(i=0;i<7;i++)
  91.         {
  92.             if(cards[i].suit==0) kolor[i]=cards[i].value;
  93.         }
  94.         sortowanie(kolor, 7);
  95.         for(i=3; i>0; i--)
  96.         {
  97.             str8=0;
  98.             for(j=i+3;j>i-1;j--)
  99.             {
  100.                 if(kolor[j]-1 == kolor[j-1]) str8 ++;
  101.             }
  102.             if(str8 == 4)
  103.             {
  104.                 value = str8flush + (kolor[j+4]*5-10);
  105.                 break;
  106.             }
  107.         }
  108.         if (value == 0)  // przypadek Ah2h3h4h5h
  109.         {
  110.             str8 = 0;
  111.             for(i=0;i<7;i++)
  112.             {
  113.                 if(kolor[i] == 0 || kolor[i] == 1 || kolor[i] == 2 || kolor[i] == 3 || kolor[i] == 12)
  114.                     str8 ++;
  115.             }
  116.             if(str8 == 5) value = str8flush + 6;
  117.         }
  118.     }
  119.     else if(diamonds>=5)
  120.     {
  121.        for(i=0;i<7;i++)
  122.         {
  123.             if(cards[i].suit==0) kolor[i]=cards[i].value;
  124.         }
  125.         sortowanie(kolor, 7);
  126.         for(i=3; i>0; i--)
  127.         {
  128.             str8=0;
  129.             for(j=i+3;j>i-1;j--)
  130.             {
  131.                 if(kolor[j]-1 == kolor[j-1]) str8 ++;
  132.             }
  133.             if(str8 == 4)
  134.             {
  135.                 value = str8flush + (kolor[j+4]*5-10);
  136.                 break;
  137.             }
  138.         }
  139.         if (value == 0)  // przypadek Ah2h3h4h5h
  140.         {
  141.             str8 = 0;
  142.             for(i=0;i<7;i++)
  143.             {
  144.                 if(kolor[i] == 0 || kolor[i] == 1 || kolor[i] == 2 || kolor[i] == 3 || kolor[i] == 12)
  145.                     str8 ++;
  146.             }
  147.             if(str8 == 5) value = str8flush + 6;
  148.         }
  149.     }
  150.     else if(hearts>=5)
  151.     {
  152.         for(i=0;i<7;i++)
  153.         {
  154.             if(cards[i].suit==0) kolor[i]=cards[i].value;
  155.         }
  156.         sortowanie(kolor, 7);
  157.         for(i=3; i>0; i--)
  158.         {
  159.             str8=0;
  160.             for(j=i+3;j>i-1;j--)
  161.             {
  162.                 if(kolor[j]-1 == kolor[j-1]) str8 ++;
  163.             }
  164.             if(str8 == 4)
  165.             {
  166.                 value = str8flush + (kolor[j+4]*5-10);
  167.                 break;
  168.             }
  169.         }
  170.         if (value == 0)  // przypadek Ah2h3h4h5h
  171.         {
  172.             str8 = 0;
  173.             for(i=0;i<7;i++)
  174.             {
  175.                 if(kolor[i] == 0 || kolor[i] == 1 || kolor[i] == 2 || kolor[i] == 3 || kolor[i] == 12)
  176.                     str8 ++;
  177.             }
  178.             if(str8 == 5) value = str8flush + 6;
  179.         }
  180.     }
  181.     else if(spades>=5)
  182.     {
  183.         for(i=0;i<7;i++)
  184.         {
  185.             if(cards[i].suit==0) kolor[i]=cards[i].value;
  186.         }
  187.         sortowanie(kolor, 7);
  188.         for(i=3; i>0; i--)
  189.         {
  190.             str8=0;
  191.             for(j=i+3;j>i-1;j--)
  192.             {
  193.                 if(kolor[j]-1 == kolor[j-1]) str8 ++;
  194.             }
  195.             if(str8 == 4)
  196.             {
  197.                 value = str8flush + (kolor[j+4]*5-10);
  198.                 break;
  199.             }
  200.         }
  201.         if (value == 0)  // przypadek Ah2h3h4h5h
  202.         {
  203.             str8 = 0;
  204.             for(i=0;i<7;i++)
  205.             {
  206.                 if(kolor[i] == 0 || kolor[i] == 1 || kolor[i] == 2 || kolor[i] == 3 || kolor[i] == 12)
  207.                     str8 ++;
  208.             }
  209.             if(str8 == 5) value = str8flush + 6;
  210.         }
  211.     }
  212. return value;
  213. }
  214. int checkQuads(card cards[])
  215. {
  216.     int i, j;
  217.     int value=0;
  218.     int sameCard;
  219.     int kicker;
  220.     int fourOfaKind=0;
  221.     for(i=6;i>=0;i--)
  222.     {
  223.         sameCard = 0;
  224.         for(j=6;j>=0;j--)
  225.         {
  226.             if(cards[i].value == cards[j].value)
  227.             {
  228.                 sameCard++;
  229.                 fourOfaKind = cards[i].value;
  230.             }
  231.         }
  232.         if (sameCard == 4)
  233.         {
  234.             for(i=6;i>=0;i--)
  235.             {
  236.                 if(cards[i].value != fourOfaKind)
  237.                 {
  238.                    kicker = cards[i].value;
  239.                    break;
  240.                 }
  241.             }
  242.             value = quads + fourOfaKind*4*5 + kicker;
  243.             break;
  244.         }
  245.     }
  246. return value;
  247. }
  248. int checkFH(card cards[])
  249. {
  250.     int i, j;
  251.     int value = 0;
  252.     int sameCard;
  253.     int trips = 0;
  254.     int pair = 0;
  255.     for(i=6;i>=0;i--)
  256.     {
  257.         sameCard=0;
  258.         for(j=6;j>=0;j--)
  259.         {
  260.             if(cards[i].value == cards[j].value)
  261.             {
  262.                 sameCard ++;
  263.                 trips = cards[i].value;
  264.             }
  265.         }
  266.         if(sameCard == 3)
  267.         {
  268.             for(i=6;i>=0;i--)
  269.             {
  270.                 sameCard=0;
  271.                 for(j=6;j>=0;j--)
  272.                 {
  273.                     if(cards[i].value != trips)
  274.                     {
  275.                         if(cards[i].value == cards[j].value)
  276.                         {
  277.                             sameCard ++;
  278.                             pair = cards[i].value;
  279.                         }
  280.                     }
  281.                 }
  282.                 if(sameCard == 3)
  283.                 {
  284.                     if(pair>trips) value = boat + 3*pair+2*trips;
  285.                     else if(trips>pair) value = boat + 3*trips + 2*trips;
  286.                     break;
  287.                 }
  288.                 else if(sameCard == 2)
  289.                 {
  290.                     value = boat + 3*trips + 2*pair;
  291.                     break;
  292.                 }
  293.             }
  294.             break;
  295.         }
  296.     }
  297. return value;
  298. }
  299. int checkFlush(card cards[])
  300. {
  301.     int clubs = 0;
  302.     int diamonds = 0;
  303.     int hearts = 0;
  304.     int spades = 0;
  305.     int i;
  306.     int value = 0;
  307.     for(i=0;i<7;i++)
  308.     {
  309.         if(cards[i].suit==0) clubs++;
  310.         else if(cards[i].suit==1) diamonds++;
  311.         else if(cards[i].suit==2) hearts++;
  312.         else if(cards[i].suit==3) spades++;
  313.     }
  314.     int kolor[7]={0};
  315.     if(clubs>=5)
  316.     {
  317.         value=flush;
  318.         for(i=0;i<7;i++)
  319.         {
  320.             if(cards[i].suit==0) kolor[i]=cards[i].value;
  321.         }
  322.         sortowanie(kolor, 7);
  323.         value += kolor[6]*15+kolor[5]+kolor[4]+kolor[3]+kolor[2];
  324.     }
  325.     else if(diamonds>=5)
  326.     {
  327.         value=flush;
  328.         for(i=0;i<7;i++)
  329.         {
  330.             if(cards[i].suit==1) kolor[i]=cards[i].value;
  331.         }
  332.         sortowanie(kolor, 7);
  333.         value += kolor[6]*15+kolor[5]+kolor[4]+kolor[3]+kolor[2];
  334.     }
  335.     else if(hearts>=5)
  336.     {
  337.         value=flush;
  338.         for(i=0;i<7;i++)
  339.         {
  340.             if(cards[i].suit==2) kolor[i]=cards[i].value;
  341.         }
  342.         sortowanie(kolor, 7);
  343.         value += kolor[6]*15+kolor[5]+kolor[4]+kolor[3]+kolor[2];
  344.     }
  345.     else if(spades>=5)
  346.     {
  347.         value=flush;
  348.         for(i=0;i<7;i++)
  349.         {
  350.             if(cards[i].suit==3) kolor[i]=cards[i].value;
  351.         }
  352.         sortowanie(kolor, 7);
  353.         value += kolor[6]*15+kolor[5]+kolor[4]+kolor[3]+kolor[2];
  354.     }
  355. return value;
  356. }
  357. int checkStr8(card cards[])
  358. {
  359.     int i;
  360.     int j;
  361.     int str8 = 0;
  362.     int value = 0;
  363.     int sameCard = 0;
  364.     for(i=3;i>0;i--)
  365.     {
  366.         str8=0;
  367.         for(j=i+3;j>i-1;j--)
  368.         {
  369.            if(cards[j].value-1==cards[j-1].value) str8++;
  370.            else if(cards[j].value==cards[j-1].value)
  371.            {
  372.                i--;
  373.                sameCard++;
  374.            }
  375.         }
  376.         if(str8==4)
  377.         {
  378.             value = straight;
  379.             if(sameCard == 0)
  380.             {
  381.                value += cards[j+4].value*5-10;
  382.             }
  383.             if(sameCard == 1)
  384.             {
  385.               value += cards[j+5].value*5-10;
  386.             }
  387.             if(sameCard == 2)
  388.             {
  389.                 value += cards[j+6].value*5-10;
  390.             }
  391.             break;
  392.         }
  393.     }
  394.     if(value == 0) // strit: A2345
  395.     {
  396.         str8=0;
  397.         for(i=0;i<7;i++)
  398.         {
  399.             if(cards[i].value == 12 || cards[i].value == 0 || cards[i].value == 1 || cards[i].value == 2 || cards[i].value == 3)
  400.                 str8 ++;
  401.         }
  402.         for(i=0;i<7;i++)
  403.         {
  404.             for(j=0;j<7;j++)
  405.             {
  406.                 if(cards[i].value == cards[j].value && i!=j && (cards[i].value == 12 || cards[i].value == 0 || cards[i].value == 1 || cards[i].value == 2 || cards[i].value == 3))
  407.                 {
  408.                     str8 --;
  409.                 }
  410.             }
  411.         }
  412.         if(str8 == 5)
  413.         {
  414.             value = straight + 6;
  415.         }
  416.     }
  417. return value;
  418. }
  419. int checkTrips(card cards[])
  420. {
  421.     int i,j;
  422.     int value=0;
  423.     int sameCard;
  424.     int trips;
  425.     int kicker[4];
  426.     for(i=6;i>=0;i--)
  427.     {
  428.         sameCard = 0;
  429.         for(j=6;j>=0;j--)
  430.         {
  431.             if(cards[i].value == cards[j].value)
  432.             {
  433.                 sameCard ++;
  434.                 trips = cards[i].value;
  435.             }
  436.         }
  437.         if(sameCard == 3)
  438.         {
  439.             j=3;
  440.             for(i=6;i>=0;i--)
  441.             {
  442.                if(cards[i].value != trips)
  443.                {
  444.                   kicker[j] = cards[i].value;
  445.                   j--;
  446.                }
  447.              }
  448.              value = threeOfaKind + trips*3*6 + kicker[3] + kicker [2];
  449.              break;
  450.         }
  451.     }
  452. return value;
  453. }
  454. int check2Pairs(card cards[])
  455. {
  456.     int i, j;
  457.     int value = 0;
  458.     int sameCard;
  459.     int pair1=0;
  460.     int pair2=0;
  461.     int kicker;
  462.     for(i=6;i>=0;i--)
  463.     {
  464.         sameCard=0;
  465.         for(j=6;j>=0;j--)
  466.         {
  467.             if(cards[i].value == cards[j].value)
  468.             {
  469.                 sameCard ++;
  470.                 pair1 = cards[i].value;
  471.             }
  472.         }
  473.         if(sameCard == 2)
  474.         {
  475.             for(i=6;i>=0;i--)
  476.             {
  477.                 sameCard = 0;
  478.                 for(j=6;j>=0;j--)
  479.                 {
  480.                     if(cards[i].value != pair1)
  481.                     {
  482.                         if(cards[i].value == cards[j].value)
  483.                         {
  484.                             sameCard ++;
  485.                             pair2 = cards[i].value;
  486.                         }
  487.                     }
  488.                 }
  489.                 if(sameCard == 2)
  490.                 {
  491.                    for(i=6;i>=0;i--)
  492.                    {
  493.                       if(cards[i].value != pair1 && cards[i].value != pair2)
  494.                       {
  495.                           kicker = cards[i].value;
  496.                           break;
  497.                       }
  498.                     }
  499.                     value = twopairs + pair1*2*3 + pair2*2*2 + kicker;
  500.                     break;
  501.                 }
  502.             }
  503.             break;
  504.         }
  505.     }
  506.  
  507. return value;
  508. }
  509. int checkPair(card cards[])
  510. {
  511.     int i,j,k;
  512.     int value=0;
  513.     int pair1;
  514.     int sameCard;
  515.     int kicker[5];
  516.     for(i=6;i>=0;i--)
  517.     {
  518.         sameCard = 0;
  519.         for(j=6;j>=0;j--)
  520.         {
  521.             if(cards[i].value == cards[j].value)
  522.             {
  523.                 sameCard ++;
  524.                 pair1 = cards[i].value;
  525.             }
  526.         }
  527.         if(sameCard == 2)
  528.         {
  529.             k=4;
  530.             for(i=6;i>=0;i--)
  531.             {
  532.                 if(cards[i].value != pair1)
  533.                 {
  534.                     kicker[k] = cards[i].value;
  535.                     k--;
  536.                 }
  537.             }
  538.             value = pair + pair1*2*10 + kicker[4] + kicker [3] + kicker [2]; // nie zmieniac tego na *20 2 i 10 repreznetuja *2 bo para * 6 zeby 33 z najgorszymi kickerami pokonala 22 z AKQ.
  539.             break;
  540.         }
  541.     }
  542. return value;
  543. }
  544. handStrength showdown(card cards[])
  545. {
  546.     card Hand1[7];
  547.     card Hand2[7];
  548.     handStrength Sila;
  549.     Sila.hand1 = 0;
  550.     Sila.hand2 = 0;
  551.     int kicker1[5];
  552.     int kicker2[5];
  553.     int i, j;
  554.     for(i=0;i<7;i++)                        // przydzielenie kart do do rak (pierwsze 7 reka nr 1 od 3 do 9 reka nr 2)
  555.     {
  556.         Hand1[i].value=cards[i].value;
  557.         Hand1[i].suit=cards[i].suit;
  558.     }
  559.     for(i=2;i<9;i++)
  560.     {
  561.         Hand2[i-2].value=cards[i].value;
  562.         Hand2[i-2].suit=cards[i].suit;
  563.     }
  564.     sortowanie_kart(Hand1, 7);
  565.     sortowanie_kart(Hand2, 7);
  566.     Sila.hand1 = checkStr8Flush(Hand1);
  567.     if(Sila.hand1 == 0) Sila.hand1 = checkQuads(Hand1);
  568.     if(Sila.hand1 == 0) Sila.hand1 = checkFH(Hand1);
  569.     if(Sila.hand1 == 0) Sila.hand1 = checkFlush(Hand1);
  570.     if(Sila.hand1 == 0) Sila.hand1 = checkStr8(Hand1);
  571.     if(Sila.hand1 == 0) Sila.hand1 = checkTrips(Hand1);
  572.     if(Sila.hand1 == 0) Sila.hand1 = check2Pairs(Hand1);
  573.     if(Sila.hand1 == 0) Sila.hand1 = checkPair(Hand1);
  574.  
  575.     Sila.hand2 = checkStr8Flush(Hand2);
  576.     if(Sila.hand2 == 0) Sila.hand2 = checkQuads(Hand2);
  577.     if(Sila.hand2 == 0) Sila.hand2 = checkFH(Hand2);
  578.     if(Sila.hand2 == 0) Sila.hand2 = checkFlush(Hand2);
  579.     if(Sila.hand2 == 0) Sila.hand2 = checkStr8(Hand2);
  580.     if(Sila.hand2 == 0) Sila.hand2 = checkTrips(Hand2);
  581.     if(Sila.hand2 == 0) Sila.hand2 = check2Pairs(Hand2);
  582.     if(Sila.hand2 == 0) Sila.hand2 = checkPair(Hand2);
  583.  
  584.     if(Sila.hand1 == 0 && Sila.hand2 == 0)
  585.     {
  586.        for(i=6;i>=2;i--) kicker1[i-2] = Hand1[i].value;  // przydzielenie sily rak jezeli reka nie zaweira zadnego ukladu
  587.        for(i=6;i>=2;i--) kicker2[i-2] = Hand2[i].value;
  588.        for(j=4;j>=0;j--)
  589.        {
  590.            Sila.hand1 = kicker1[j];
  591.            Sila.hand2 = kicker2[j];
  592.            if(Sila.hand1 != Sila.hand2) break;
  593.        }
  594.     }
  595.  
  596. return Sila;
  597. }
  598. game blinds(game round, int blind, int roundnumber)
  599. {
  600.     round.pot = 0;
  601.     if(roundnumber%2 == 1) // gracz na BB np 1. reka
  602.     {
  603.         if(round.stack1 <= blind/2)
  604.         {
  605.             round.pot = 2* round.stack1;
  606.             round.stack2 -= round.stack1;
  607.             round.stack1 = 0;
  608.         }
  609.         else if(round.stack2 <= blind/2)
  610.         {
  611.             round.pot = 2* round.stack2;
  612.             round.stack1 -= round.stack2;
  613.             round.stack2 = 0;
  614.         }
  615.         else if(round.stack1 >= blind) // gracz na big blindzie
  616.         {
  617.             round.stack1 -= blind;
  618.             round.pot += blind;
  619.         }
  620.         else if(round.stack1 < blind)
  621.         {
  622.             round.pot += round.stack1;
  623.             round.stack1 = 0;
  624.         }
  625.         if (round.stack2 >= blind/2)
  626.         {
  627.             round.stack2 -= blind/2;
  628.             round.pot += blind/2;
  629.         }
  630.     }
  631.     else if(roundnumber%2 == 0)
  632.     {
  633.         if(round.stack1 <= blind/2)
  634.         {
  635.             round.pot = 2* round.stack1;
  636.             round.stack2 -= round.stack1;
  637.             round.stack1 = 0;
  638.         }
  639.         else if(round.stack2 <= blind/2)
  640.         {
  641.             round.pot = 2* round.stack2;
  642.             round.stack1 -= round.stack2;
  643.             round.stack2 = 0;
  644.         }
  645.         else if(round.stack2 >= blind) // komputer na big blindzie
  646.         {
  647.             round.stack2 -= blind;
  648.             round.pot += blind;
  649.         }
  650.         else if(round.stack1 < blind)
  651.         {
  652.             round.pot += round.stack1;
  653.             round.stack2 = 0;
  654.         }
  655.         if (round.stack1 >= blind/2)
  656.         {
  657.             round.stack1 -= blind/2;
  658.             round.pot += blind/2;
  659.         }
  660.     }
  661. return round;
  662. }
  663. game winner(game round, handStrength value)
  664. {
  665.     if(value.hand1 > value.hand2)
  666.     {
  667.        round.stack1 += round.pot;
  668.        printf("\nyou won the hand\n");
  669.     }
  670.     else if(value.hand1 < value.hand2)
  671.     {
  672.         round.stack2 += round.pot;
  673.         printf("\ncomputer won the hand\n");
  674.     }
  675.     else if(value.hand2 == value.hand1)
  676.     {
  677.         round.stack2 += round.pot/2;
  678.         round.stack1 += round.pot/2;
  679.     }
  680. return round;
  681. }
  682. game preFlopDecision(game round, int blind, int roundnumber)
  683. {
  684.     int choice;
  685.     int i;
  686.     int previousBet;
  687.     int previousBet2;
  688.     int position;
  689.     int allinstack1 = round.stack1;
  690.     int allinstack2 = round.stack2;
  691.     round.decisionOn = roundnumber%2;
  692.     position = round.decisionOn;
  693.     round.bet = blind/2;
  694.     previousBet = blind;
  695.     while(round.decisionOn == 0 || round.decisionOn == 1)
  696.     {
  697.           if(round.decisionOn == 0 ) // decyzja gracza
  698.           {
  699.              for(i=1;i<2;i++)
  700.              {
  701.                 if(round.pot == 2*blind && position == 1 && round.bet < 2*blind ) // preflop in position na big blindzie gdy oppoenent zagral call
  702.                 {
  703.                     printf(" \n1. fold  2. check 3.raise");
  704.                     scanf("%d", &choice);
  705.                     if(choice == 1)
  706.                     {
  707.                        round.stack2 += round.pot;
  708.                        round.decisionOn = 3;
  709.                     }
  710.                     else if(choice == 2 )
  711.                     {
  712.                         round.bet = 0;
  713.                         round.decisionOn = 2;
  714.                     }
  715.                     else if(choice == 3)
  716.                     {
  717.                         printf("\n how much to raise: ");
  718.                         previousBet = blind;
  719.                         round.stack1 += previousBet;
  720.                         round.pot -= previousBet;
  721.                         previousBet2 = previousBet;
  722.                         previousBet = round.bet;
  723.                         scanf("%d", &round.bet);
  724.                         if(round.bet < 2*blind)
  725.                         {
  726.                             printf("You must raise min 2BB");
  727.                             round.bet = previousBet;
  728.                             round.stack1 -= previousBet2;
  729.                             round.pot += previousBet2;
  730.                             i --;
  731.                         }
  732.                         else if(round.bet >= 2*blind && round.bet <= round.stack1)
  733.                         {
  734.                             round.stack1 += previousBet;
  735.                             round.stack1 -= round.bet;
  736.                             round.pot += round.bet;
  737.                             printf("\npot: %d", round.pot);
  738.                             round.decisionOn = 1;
  739.                         }
  740.                         else
  741.                         {
  742.                             printf("if you wanna raise that much buy more chips... you dont have enough money");
  743.                             round.bet = previousBet;
  744.                             round.stack1 -= previousBet2;
  745.                             round.pot += previousBet2;
  746.                             continue;
  747.                         }
  748.                     }
  749.                     else
  750.                     {
  751.                         printf("wrong choice, pick again");
  752.                         i --;
  753.                     }
  754.                 }
  755.                 else if(round.pot == (blind+blind/2) && position == 0) // preflop out of positon na small blindzie
  756.                 {
  757.                         printf(" 1. fold \n 2. call %d 3. raise", round.bet);
  758.                         scanf("%d", &choice);
  759.                         if(choice == 1)
  760.                         {
  761.                           round.stack2 += round.pot;
  762.                           round.decisionOn = 3;
  763.                         }
  764.                         else if(choice == 2)
  765.                         {
  766.                                 round.stack1 -= round.bet;
  767.                                 round.pot += round.bet;
  768.                                 printf("pot: %d\n", round.pot);
  769.                                 round.decisionOn = 1;
  770.                         }
  771.                         else if(choice == 3)
  772.                         {
  773.                                 printf("\n how much to raise: ");
  774.                                 previousBet = blind/2;
  775.                                 previousBet2 = previousBet;
  776.                                 round.stack1 += previousBet2;
  777.                                 round.pot -= previousBet2;
  778.                                 scanf("%d", &round.bet);
  779.                                 if(round.bet < 2*blind)
  780.                                 {
  781.                                     printf("you must raise min 2BB\n");
  782.                                     round.bet = previousBet;
  783.                                     round.stack1 -= previousBet2;
  784.                                     round.pot += previousBet2;
  785.                                     i --;
  786.                                 }
  787.                                 else if(round.bet >= 2*blind && round.bet <= round.stack1)
  788.                                 {
  789.                                     round.stack1 -= round.bet;
  790.                                     round.pot += round.bet;
  791.                                     round.decisionOn = 1;
  792.                                     printf("\n pot %d \n \n your stack: %d \n",round.pot, round.stack1);
  793.                                 }
  794.                                 else
  795.                                 {
  796.                                 printf("if you wanna raise that much buy more chips... you dont have enough money");
  797.                                 round.bet = previousBet;
  798.                                 round.stack1 -= previousBet2;
  799.                                 round.pot += previousBet2;
  800.                                 i --;
  801.                                 }
  802.                         }
  803.                         else
  804.                         {
  805.                            printf("wrong choice, pick again");
  806.                            i --;
  807.                         }
  808.                  }
  809.                  else if(round.pot > 2*blind)
  810.                  {
  811.                         printf(" 1. fold \n 2. call %d 3. raise", round.bet);
  812.                         scanf("%d", &choice);
  813.                         if(choice == 1)
  814.                         {
  815.                             round.stack2 += round.pot;
  816.                             round.decisionOn = 3;
  817.                         }
  818.  
  819.                         if(choice == 2)
  820.                         {
  821.                             round.stack1 += previousBet;
  822.                             round.pot -= previousBet;
  823.                             round.stack1 -= round.bet;
  824.                             round.pot += round.bet;
  825.                             round.decisionOn = 2;
  826.                         }
  827.                         if(choice == 3)
  828.                         {
  829.                             printf("\nhow much to raise: ");
  830.                             round.stack1 += previousBet;
  831.                             round.pot -= previousBet;
  832.                             previousBet2 = previousBet;
  833.                             previousBet = round.bet;
  834.                             scanf("%d", &round.bet);
  835.                             if(round.bet < (previousBet + blind))
  836.                             {
  837.                                 printf("you must raise min previous bet + 1BB");
  838.                                 round.bet = previousBet;
  839.                                 round.stack1 -= previousBet2;
  840.                                 round.pot += previousBet2;
  841.                                 i--;
  842.                             }
  843.                             else if(round.bet > round.pot + blind && round.bet <= round.stack1)
  844.                             {
  845.                                 round.stack1 += previousBet;
  846.                                 round.pot -= previousBet;
  847.                                 round.stack1 -= round.bet;
  848.                                 round.pot += round.bet;
  849.                                 round.decisionOn = 1;
  850.                             }
  851.                             else
  852.                             {
  853.                                 printf("if you wanna raise that much buy more chips... you dont have enough money");
  854.                                 round.bet = previousBet;
  855.                                 round.stack1 -= previousBet2;
  856.                                 round.pot += previousBet2;
  857.                                 i--;
  858.                             }
  859.                         }
  860.                  }
  861.                  else if(round.pot < (3*blind/2)) round.decisionOn =3;
  862.               }
  863.           }
  864.           else if(round.decisionOn == 1)
  865.           {
  866.                   if(round.pot == 2*blind && position == 0 && round.bet < 2*blind ) // komputer na Big blindzie gdy Small blind gra call
  867.                   {
  868.                       choice = rand()%3 + 1;
  869.                       if(choice == 1)
  870.                       {
  871.                          round.stack1 += round.pot;
  872.                          round.decisionOn = 3;
  873.                          printf("computer folds. \n");
  874.                       }
  875.                       else if(choice == 2 )
  876.                       {
  877.                           round.bet = 0;
  878.                           round.decisionOn = 2;
  879.                           printf("computer checks. \n");
  880.                       }
  881.                       else if(choice == 3)
  882.                       {
  883.                           round.stack2 += 2*round.bet;
  884.                           round.pot -= 2*round.bet;
  885.                           if(round.stack2 >= round.stack1) round.bet = random(2*blind, round.stack1);
  886.                           else if(round.stack2 <= round.stack1) round.bet = random(2*blind, round.stack2);
  887.                           round.stack2 -= round.bet;
  888.                           round.pot += round.bet;
  889.                           round.decisionOn = 0;
  890.                           printf("\n computer raises to: %d \n pot is now: %d", round.bet, round.pot);
  891.                       }
  892.                   }
  893.                   else if(round.pot == (blind+blind/2) && position == 1) // komputer na sb
  894.                   {
  895.                       choice = rand()%3 + 1;
  896.                       if(choice == 1)
  897.                       {
  898.                          round.stack1 += round.pot;
  899.                          round.decisionOn = 3;
  900.                          printf("computer folds.");
  901.                       }
  902.                       else if(choice == 2)
  903.                       {
  904.                           round.stack2 -= round.bet;
  905.                           round.pot += round.bet;
  906.                           round.decisionOn = 0;
  907.                           printf("computer calls pot is now: %d", round.pot);
  908.                       }
  909.                       else if(choice == 3)
  910.                       {
  911.                           int open;
  912.                           open = rand()%2;
  913.                           previousBet = blind;
  914.                           round.stack2 += round.bet;
  915.                           round.pot -= round.bet;
  916.                           if(round.stack2 >= 3*blind && open == 0) round.bet = 3*blind;
  917.                           else if(round.stack2 >= round.stack1) round.bet = random(2*blind, allinstack1);
  918.                           else if(round.stack2 <= round.stack1) round.bet = random(2*blind, allinstack2);
  919.                           round.stack2 -= round.bet;
  920.                           round.pot += round.bet;
  921.                           round.decisionOn = 0;
  922.                           printf("\n computer raises to: %d \n his stack is now: %d  pot is now: %d\n", round.bet, round.stack2, round.pot);
  923.                       }
  924.                   }
  925.                   else if(round.pot >= 2*blind)
  926.                   {
  927.                       choice = rand()%3 + 1;
  928.                       if(choice == 1)
  929.                       {
  930.                           round.stack1 += round.pot;
  931.                           round.decisionOn = 3;
  932.                           printf("computer folds.\n");
  933.                       }
  934.                       else if(choice == 2 && round.bet < (round.stack2 + previousBet))
  935.                       {
  936.                           round.stack2 += previousBet;
  937.                           round.pot -= previousBet;
  938.                           round.stack2 -= round.bet;
  939.                           round.pot += round.bet;
  940.                           round.decisionOn = 2;
  941.                           printf("computer calls, pot is now: %d", round.pot);
  942.                       }
  943.                       else if(choice == 2 && round.bet >= allinstack2)
  944.                       {
  945.  
  946.                           if( allinstack1 > allinstack2)
  947.                           {
  948.                                round.stack1 += round.bet;
  949.                                round.stack1 -= (round.stack2 + previousBet);
  950.                                round.pot -= round.bet;
  951.                                round.pot += round.stack2 + previousBet;
  952.                                round.pot += round.stack2 + previousBet;
  953.                                round.stack2 -= round.stack2;
  954.                           }
  955.                           else
  956.                           {
  957.                                round.pot += round.stack1;
  958.                                round.pot += round.stack2;
  959.                                round.stack1 = 0;
  960.                                round.stack2 = 0;
  961.                           }
  962.                           printf("computer calls and is all in pot is now : %d", round.pot);
  963.                           round.decisionOn = 2;
  964.                       }
  965.                       else if(choice == 3 && round.bet < (round.stack2 + blind) && round.stack1 != 0)
  966.                       {
  967.                           round.stack2 += previousBet;
  968.                           round.pot -= previousBet;
  969.                           if(round.stack2 >= round.stack1) round.bet = random(2*blind, allinstack1);
  970.                           else if(round.stack2 <= round.stack1) round.bet = random(2*blind, allinstack2);
  971.                           round.stack2 -= round.bet;
  972.                           round.pot += round.bet;
  973.                           printf("computer raises to: %d, pot is now: %d", round.bet, round.pot);
  974.                           round.decisionOn = 0;
  975.                       }
  976.                       else if(choice == 3 && round.bet >= round.stack2)
  977.                       {
  978.  
  979.                           if(allinstack1 > allinstack2)
  980.                           {
  981.                                round.stack1 += round.bet;
  982.                                round.stack1 -= (round.stack2 + previousBet);
  983.                                round.pot -= round.bet;
  984.                                round.pot += round.stack2 + previousBet;
  985.                                round.pot += round.stack2 + previousBet;
  986.                                round.stack2 -= round.stack2;
  987.                           }
  988.                           else
  989.                           {
  990.                                round.pot += round.stack1;
  991.                                round.pot += round.stack2;
  992.                                round.stack1 = 0;
  993.                                round.stack2 = 0;
  994.                           }
  995.                           printf("computer calls and is all in pot is now : %d", round.pot);
  996.                           round.decisionOn = 2;
  997.                       }
  998.                       else if(choice == 3 && round.stack1 == 0)
  999.                       {
  1000.                           round.stack2 += previousBet;
  1001.                           round.pot -= previousBet;
  1002.                           round.stack2 -= round.bet;
  1003.                           round.pot += round.bet;
  1004.                           round.decisionOn = 2;
  1005.                           printf("computer calls, pot is now: %d", round.pot);
  1006.                       }
  1007.                   }
  1008.                   else if(round.pot < (3*blind/2)) round.decisionOn =3;
  1009.           }
  1010.    }
  1011. return round;
  1012. }
  1013. game postFlopDecision(game round, int blind, int roundnumber)
  1014. {
  1015.     int choice;
  1016.     int compChoice;
  1017.     int i;
  1018.     int position;
  1019.     int previousBet;
  1020.     int allinstack1 = round.stack1;
  1021.     int allinstack2 = round.stack2;
  1022.     round.decisionOn = roundnumber%2;
  1023.     position = round.decisionOn;
  1024.     round.bet = 0;
  1025.     previousBet = 0;
  1026.     int previousBet2;
  1027.     while(round.decisionOn == 0 || round.decisionOn == 1)
  1028.     {
  1029.           if(round.decisionOn == 0)
  1030.           {
  1031.               for(i=1;i<2;i++)
  1032.               {
  1033.                   if(position == 0 && round.bet == 0)// OOP FLOP DECISION
  1034.                   {
  1035.                       printf("\n 1.fold 2.check 3.bet \n");
  1036.                       scanf("%d", &choice);
  1037.                       if(choice == 1)
  1038.                       {
  1039.                           round.stack2 += round.pot;
  1040.                           round.decisionOn = 3;
  1041.                       }
  1042.                       else if(choice == 2)
  1043.                       {
  1044.                           round.decisionOn = 1; //check oop decyzja do komputera
  1045.                       }
  1046.                       else if(choice == 3)
  1047.                       {
  1048.                           printf("how much to bet: ");
  1049.                           scanf("%d", &round.bet);
  1050.                           if(round.bet < blind)
  1051.                           {
  1052.                               printf("you must bet min 1bb \n");
  1053.                               i --;
  1054.                           }
  1055.                           else if(round.bet > round.stack1)
  1056.                           {
  1057.                               printf("if you wanna raise that much buy more chips... you dont have enough money \n");
  1058.                               i --;
  1059.                           }
  1060.                           else if(round.bet >= blind && round.bet <= round.stack1)
  1061.                           {
  1062.                               round.stack1 -= round.bet;
  1063.                               round.pot += round.bet;
  1064.                               round.decisionOn = 1;
  1065.                           }
  1066.                       }
  1067.                   }
  1068.                   else if(position == 0 && round.bet > 0) // oop comp reraised
  1069.                   {
  1070.                        printf("\n 1.fold 2.call %d 3.bet \n", round.bet);
  1071.                        scanf("%d", &choice);
  1072.                        if(choice == 1)
  1073.                        {
  1074.                             round.stack2 += round.pot; // fold
  1075.                             round.decisionOn = 3;
  1076.                        }
  1077.                        else if(choice == 2)
  1078.                        {
  1079.                                 round.stack1 += previousBet;
  1080.                                 round.pot -= previousBet;
  1081.                                 round.stack1 -= round.bet;
  1082.                                 round.pot += round.bet;
  1083.                                 round.decisionOn = 2; //call back, next street
  1084.                        }
  1085.                        else if(choice == 3)
  1086.                        {
  1087.                             printf("how much to raise: ");
  1088.                             round.stack1 += previousBet;
  1089.                             round.pot -= previousBet;
  1090.                             previousBet2 = previousBet;
  1091.                             previousBet = round.bet;
  1092.                             scanf("%d", &round.bet);
  1093.                             if(round.bet < (previousBet+blind))
  1094.                             {
  1095.                                 printf("you have raise to min prev bet + 1bb");
  1096.                                 i --;
  1097.                                 round.bet = previousBet;
  1098.                                 round.stack1 -= previousBet2;
  1099.                                 round.pot += previousBet2;
  1100.                             }
  1101.                             else if(round.bet > round.stack1)
  1102.                             {
  1103.                                 printf("if you wanna raise that much buy more chips... you dont have enough money\n");
  1104.                                 i --;
  1105.                                 round.bet = previousBet;
  1106.                                 round.stack1 -= previousBet2;
  1107.                                 round.pot += previousBet2;
  1108.                             }
  1109.                             else
  1110.                             {
  1111.                                 round.stack1 -= round.bet;
  1112.                                 round.pot += round.bet;
  1113.                                 round.decisionOn = 1;
  1114.                                 printf("your stack is now: %d     pot is now: %d", round.stack1, round.pot);
  1115.                             }
  1116.                          }
  1117.                   }
  1118.                   else if(position == 1) // IP POST FLOP
  1119.                   {
  1120.                           if(round.bet == 0) // komputer gral check
  1121.                           {
  1122.                              printf("\n 1.fold 2.check 3.bet \n");
  1123.                              scanf("%d", &choice);
  1124.                              if(choice == 1)
  1125.                              {
  1126.                                 round.stack2 += round.pot; // fold
  1127.                                 round.decisionOn = 3;
  1128.                              }
  1129.                              else if(choice == 2)
  1130.                              {
  1131.                                 round.decisionOn = 2; //check back, next street
  1132.                              }
  1133.                              else if(choice == 3) // bet IP
  1134.                              {
  1135.                                  printf("how much to bet: ");
  1136.                                  scanf("%d", &round.bet);
  1137.                                  if(round.bet < blind)
  1138.                                  {
  1139.                                      printf("you must bet min 1bb \n");
  1140.                                      i --;
  1141.                                  }
  1142.                                  else if(round.bet > round.stack1)
  1143.                                  {
  1144.                                      printf("if you wanna raise that much buy more chips... you dont have enough money \n");
  1145.                                      i --;
  1146.                                  }
  1147.                                  else if(round.bet >= blind && round.bet <= round.stack1)
  1148.                                  {
  1149.                                      round.stack1 -= round.bet;
  1150.                                      round.pot += round.bet;
  1151.                                      round.decisionOn = 1;
  1152.                                      printf("your stack is now: %d     pot is now: %d", round.stack1, round.pot);
  1153.                                  }
  1154.                              }
  1155.                           }
  1156.                           else if(round.bet > 0) // komp gra bet
  1157.                           {
  1158.                               printf("\n 1.fold 2.call %d 3.raise \n", round.bet);
  1159.                               scanf("%d", &choice);
  1160.                               if(choice == 1)
  1161.                               {
  1162.                                  round.stack2 += round.pot; // fold
  1163.                                  round.decisionOn = 3;
  1164.                               }
  1165.                               else if(choice == 2)
  1166.                               {
  1167.                                   round.stack1 -= round.bet;
  1168.                                   round.pot += round.bet;
  1169.                                   printf("pot is now %d \n", round.pot);
  1170.                                   round.decisionOn = 2;
  1171.                               }
  1172.                               else if(choice == 3)
  1173.                               {
  1174.                                   printf("how much to raise: ");
  1175.                                   round.stack1 += previousBet;
  1176.                                   round.pot -= previousBet;
  1177.                                   previousBet2 = previousBet;
  1178.                                   previousBet = round.bet;
  1179.                                   scanf("%d", &round.bet);
  1180.                                   if(round.bet < (previousBet+blind))
  1181.                                   {
  1182.                                       printf("you have raise to min prev bet + 1bb");
  1183.                                       i --;
  1184.                                       round.bet = previousBet;
  1185.                                       round.stack1 -= previousBet2;
  1186.                                       round.pot += previousBet2;
  1187.                                   }
  1188.                                   else if(round.bet > round.stack1)
  1189.                                   {
  1190.                                       printf("if you wanna raise that much buy more chips... you dont have enough money\n");
  1191.                                       i --;
  1192.                                       round.bet = previousBet;
  1193.                                       round.stack1 -= previousBet2;
  1194.                                       round.pot += previousBet2;
  1195.                                   }
  1196.                                   else
  1197.                                   {
  1198.                                       round.stack1 -= round.bet;
  1199.                                       round.pot += round.bet;
  1200.                                       round.decisionOn = 1;
  1201.                                       printf("your stack is now: %d     pot is now: %d", round.stack1, round.pot);
  1202.                                   }
  1203.                               }
  1204.                           }
  1205.                   }
  1206.               }
  1207.           }
  1208.           else if(round.decisionOn == 1) // decyzje kompa
  1209.           {
  1210.               if(position == 1 && round.bet == 0) // OOP BOT DECISION
  1211.               {
  1212.                   compChoice = rand()%2 +1;
  1213.                   if(compChoice == 1)
  1214.                   {
  1215.                       printf("computer checks. \n");
  1216.                       round.decisionOn = 0;
  1217.                   }
  1218.                   else if(compChoice == 2)
  1219.                   {
  1220.                        if(round.stack2 >= round.pot/2)
  1221.                        {
  1222.                             round.bet = round.pot/2;
  1223.                             round.stack2 -= round.bet;
  1224.                             round.pot += round.bet;
  1225.                             printf("computer bets: %d pot is now: %d", round.bet, round.pot);
  1226.                             round.decisionOn = 0;
  1227.                         }
  1228.                         else
  1229.                         {
  1230.                             round.bet = round.stack2;
  1231.                             round.stack2 -= round.bet;
  1232.                             round.pot += round.bet;
  1233.                             printf("computer bets: %d pot is now: %d", round.bet, round.pot);
  1234.                             round.decisionOn = 0;
  1235.                         }
  1236.                     }
  1237.                 }
  1238.                 else if(position == 0 && round.bet == 0) // KOMPUTER IP GRACZ GRA X FLOP
  1239.                 {
  1240.                     compChoice = rand()%2 +1;
  1241.                     if(compChoice == 1)
  1242.                     {
  1243.                         printf("computer checks.");
  1244.                         round.decisionOn = 2; // dealing next card;
  1245.                     }
  1246.                     else if(compChoice == 2)
  1247.                     {
  1248.                         if(round.stack2 >= round.pot/2) //betting always half for balance :P zmien to potem
  1249.                         {
  1250.                              round.bet = round.pot/2;
  1251.                              round.stack2 -= round.bet;
  1252.                              round.pot += round.bet;
  1253.                              printf("computer bets: %d pot is now: %d", round.bet, round.pot);
  1254.                              round.decisionOn = 0;
  1255.                         }
  1256.                         else
  1257.                         {
  1258.                              round.bet = round.stack2;
  1259.                              round.stack2 -= round.bet;
  1260.                              round.pot += round.bet;
  1261.                              printf("computer bets: %d pot is now: %d", round.bet, round.pot);
  1262.                              round.decisionOn = 0;
  1263.                         }
  1264.                     }
  1265.                 }
  1266.                 else if(round.bet > 0) // player bet
  1267.                 {
  1268.                     compChoice = rand()%3 +1;
  1269.                     if(compChoice == 1)
  1270.                     {
  1271.                         printf("computer folds.");
  1272.                         round.stack1 += round.pot;
  1273.                         round.decisionOn = 3;
  1274.                     }
  1275.                     if(compChoice == 2)
  1276.                     {
  1277.                         printf("computer calls.");
  1278.                         round.stack2 += previousBet;
  1279.                         round.pot -= previousBet;
  1280.                         round.stack2 -= round.bet;
  1281.                         round.pot += round.bet;
  1282.                         printf("computer stack: %d pot: %d", round.stack2, round.pot);
  1283.                         round.decisionOn = 2; // dealing next card
  1284.                     }
  1285.                     if(compChoice == 3)
  1286.                     {
  1287.                         round.stack2 += previousBet;
  1288.                         round.pot -= previousBet;
  1289.                         if((round.stack1 + previousBet) > round.stack2) round.bet = random(round.bet + blind, round.stack2);
  1290.                         else if(round.stack2 > (round.stack1 + previousBet)) round.bet = random(round.bet + blind, round.stack1);
  1291.                         round.stack2 -= round.bet;
  1292.                         round.pot += round.bet;
  1293.                         round.decisionOn = 0;
  1294.                         printf("computer raises to: %d, his stack is now: %d pot is now: %d", round.bet, round.stack2, round.pot);
  1295.                     }
  1296.                 }
  1297.             }
  1298.     }
  1299.  
  1300. return round;
  1301. }
  1302. void dealer(card cards[], int ile)
  1303. {
  1304.     printf("Dealing cards... \n");
  1305.     int m;
  1306.     int i;
  1307.     int j;
  1308.     int identical;
  1309.     for(m=1;m<2;m++) // <------- LOSOWANIE 9 UNIKATOWYCH KART
  1310.     {
  1311.         for(i=0;i<ile;i++)
  1312.         {
  1313.             int randomv;
  1314.             randomv=rand()%13;
  1315.             cards[i].value=randomv;
  1316.         }
  1317.         for(i=0;i<ile;i++)
  1318.         {
  1319.             int randoms;
  1320.             randoms=rand()%4;
  1321.             cards[i].suit=randoms;
  1322.         }
  1323.         for(i=0;i<ile;i++)
  1324.         {
  1325.             identical=0;
  1326.             for(j=0;j<ile;j++)
  1327.             {
  1328.                 if(cards[j].value==cards[i].value&&cards[j].suit==cards[i].suit)
  1329.                 {
  1330.                 identical++;
  1331.                 }
  1332.             }
  1333.             if(identical>1)
  1334.             {
  1335.                 m--;
  1336.                 break;
  1337.             }
  1338.         }
  1339.     }
  1340. }
  1341. int main()
  1342. {
  1343.     srand( time( NULL ) );
  1344.     card cards[9];
  1345.     handStrength SilaRak;
  1346.     game upDate;
  1347.     upDate.stack1 = upDate.stack2 = 5000;
  1348.     int i, j;
  1349.     int blind = 100;
  1350.     int roundnumber = 0;
  1351.     printf(" Welcome to 5000 No Limit heads up poker.\n Blinds are: 50/100. \n You will be starting on Big Blind, good luck!!");
  1352.     Sleep(3000);
  1353.     printf("\n Schuffling deck:\n");
  1354.     for(j=0;j<4;j++)
  1355.     {
  1356.        for(i=0; i<13; i++)
  1357.        {
  1358.          printf(" %c%c \n",rank[i], suits[j]);
  1359.        }
  1360.        Sleep(2500);
  1361.     }
  1362.     while(upDate.stack1>0 && upDate.stack2>0)
  1363.     {
  1364.             roundnumber ++;
  1365.             upDate.bet = blind/2;
  1366.             printf("\nYour stack is: %d   Your oppoenent's stack is: %d\n", upDate.stack1, upDate.stack2);
  1367.             printf("Posting blinds. . .\n");
  1368.             Sleep(3000);
  1369.             upDate = blinds(upDate, blind, roundnumber);
  1370.             dealer(cards, 9);
  1371.             Sleep(3000);
  1372.             system("cls");
  1373.             printf("Your stack is: %d   pot is : %d   Your oppoenent's stack is: %d\n", upDate.stack1,upDate.pot , upDate.stack2);
  1374.             printf("Your hand is:\n ------   ------\n");
  1375.             printf("| %c%c   | | %c%c   |\n", rank[cards[0].value], suits[cards[0].suit], rank[cards[1].value], suits[cards[1].suit]);
  1376.             printf("|      | |      |\n");
  1377.             printf("|      | |      |\n");
  1378.             printf(" ------   ------\n");
  1379.             upDate = preFlopDecision(upDate, blind, roundnumber); //preflop
  1380.             if(upDate.decisionOn == 3) continue; // fold preflop
  1381.             else if(upDate.decisionOn == 2 && (upDate.stack1 <= 0 || upDate.stack2 <= 0)) // all in preflop
  1382.             {
  1383.                 printf("Your opponent hand is: %c%c %c%c\n", rank[cards[7].value], suits[cards[7].suit], rank[cards[8].value], suits[cards[8].suit]);
  1384.                 printf("Your stack is:%d    Your opponent stack is %d\n     pot is: %d\n", upDate.stack1, upDate.stack2, upDate.pot);
  1385.                 printf("board: ");
  1386.                 for(i=2;i<7;i++) printf("%c%c ", rank[cards[i].value], suits[cards[i].suit]);
  1387.                 SilaRak = showdown(cards);
  1388.                 upDate = winner(upDate, SilaRak);
  1389.                 printf("Your stack is: %d   Your oppoenent's stack is: %d\n", upDate.stack1, upDate.stack2);
  1390.                 Sleep(15000);
  1391.                 system("cls");
  1392.                 Sleep(5000);
  1393.             }
  1394.             else if(upDate.decisionOn == 2 && upDate.stack1 != 0 && upDate.stack2 != 0)
  1395.             {
  1396.                 printf("Your stack is:%d    Your opponent stack is %d\n     pot is: %d\n", upDate.stack1, upDate.stack2, upDate.pot);
  1397.                 printf("board: ");
  1398.                 for(i=2;i<5;i++) printf(" %c%c ", rank[cards[i].value], suits[cards[i].suit]);
  1399.                 upDate = postFlopDecision(upDate, blind, roundnumber); // flop decisions
  1400.                 if(upDate.decisionOn == 3) continue; // fold na flopie
  1401.                 else if(upDate.decisionOn == 2 && (upDate.stack1 <= 0 || upDate.stack2 <= 0)) // all in na flopie
  1402.                 {
  1403.                     printf("Your opponent hand is: %c%c %c%c\n", rank[cards[7].value], suits[cards[7].suit], rank[cards[8].value], suits[cards[8].suit]);
  1404.                     printf("Your stack is:%d    Your opponent stack is %d\n     pot is: %d\n", upDate.stack1, upDate.stack2, upDate.pot);
  1405.                     printf("board: ");
  1406.                     for(i=2;i<7;i++) printf("%c%c ", rank[cards[i].value], suits[cards[i].suit]);
  1407.                     SilaRak = showdown(cards);
  1408.                     upDate = winner(upDate, SilaRak);
  1409.                     printf("Your stack is: %d   Your oppoenent's stack is: %d\n", upDate.stack1, upDate.stack2);
  1410.                     Sleep(15000);
  1411.                     system("cls");
  1412.                     Sleep(5000);
  1413.                 }
  1414.                 else if(upDate.decisionOn == 2 && upDate.stack1 != 0 && upDate.stack2 != 0)
  1415.                 {
  1416.                    printf("board: ");
  1417.                    printf("Your stack is:%d    Your opponent stack is %d\n     pot is: %d\n", upDate.stack1, upDate.stack2, upDate.pot);
  1418.                    for(i=2;i<6;i++) printf("%c%c ", rank[cards[i].value], suits[cards[i].suit]);
  1419.                    upDate = postFlopDecision(upDate, blind, roundnumber); // turn decisions
  1420.                    if(upDate.decisionOn == 3) continue; // fold na turnie
  1421.                    else if(upDate.decisionOn == 2 && (upDate.stack1 <= 0 || upDate.stack2 <= 0)) // all in na turnie
  1422.                    {
  1423.                        printf("Your opponent hand is: %c%c %c%c\n", rank[cards[7].value], suits[cards[7].suit], rank[cards[8].value], suits[cards[8].suit]);
  1424.                        printf("Your stack is:%d    Your opponent stack is %d\n     pot is: %d\n", upDate.stack1, upDate.stack2, upDate.pot);
  1425.                        printf("board: ");
  1426.                        for(i=2;i<7;i++) printf("%c%c ", rank[cards[i].value], suits[cards[i].suit]);
  1427.                        SilaRak = showdown(cards);
  1428.                        upDate = winner(upDate, SilaRak);
  1429.                        printf("Your stack is: %d   Your oppoenent's stack is: %d\n", upDate.stack1, upDate.stack2);
  1430.                        Sleep(15000);
  1431.                        system("cls");
  1432.                        Sleep(5000);
  1433.                    }
  1434.                    else if(upDate.decisionOn == 2 && upDate.stack1 != 0 && upDate.stack2 != 0)
  1435.                    {
  1436.                         printf("Your stack is:%d    Your opponent stack is %d\n     pot is: %d\n", upDate.stack1, upDate.stack2, upDate.pot);
  1437.                         printf("board: ");
  1438.                         for(i=2;i<7;i++) printf("%c%c ", rank[cards[i].value], suits[cards[i].suit]);
  1439.                         upDate = postFlopDecision(upDate, blind, roundnumber); // river decisions
  1440.                         if(upDate.decisionOn == 3) continue; // fold na riverze
  1441.                         else if(upDate.decisionOn == 2)
  1442.                         {
  1443.                             printf("\nYour opponent hand is: %c%c %c%c\n", rank[cards[7].value], suits[cards[7].suit], rank[cards[8].value], suits[cards[8].suit]);
  1444.                             SilaRak = showdown(cards);
  1445.                             upDate = winner(upDate, SilaRak);
  1446.                             printf("\nYour stack is: %d   Your oppoenent's stack is: %d\n", upDate.stack1, upDate.stack2);
  1447.                             Sleep(15000);
  1448.                             system("cls");
  1449.                             Sleep(5000);
  1450.                         }
  1451.                    }
  1452.                 }
  1453.             }
  1454.     }
  1455. return 0;
  1456. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement