preflop_allin_B

#include "stdafx.h"
#include <iostream>

using namespace std;

float WIN[30] =
{
// AK  2P  3P  4P  5P  6P  7P  8P  9P  TP
 0.1, 0.18, 0.21, 0.24, 0.27, 0.3, 0.33, 0.37, 0.4, 0.44,

// JP  QP  KP  AP  3U  4U  5U  6U  7U  8U
 0.48, 0.52, 0.55, 0.59, 0.6, 0.61, 0.62, 0.63, 0.64, 0.66,

// 9U  TU  JU  QU  KU  AU  set  stra flush full
 0.68, 0.7, 0.72, 0.75, 0.78, 0.82, 0.85, 0.9, 0.92, 0.95,
};

struct Cards_ppt//底牌的属性
{
 int C1,C2;//两张牌的点数:2--0,...,A--12
 bool IsPair;//是否是一对
 bool IsSame;//是否同花
 int StraType;//成顺类型:0--不成顺,1--空三张,2--空两张,3--空一张,4--连张
};

struct DT{int Type; float Per;};

DT Draw_Per[2][9] =
{
// AK   P1  P2  U1    U2  set   stra flush  full 
 {{0,0.22},{0,0.24},{0,0.24},{0,0.11},{0,0.11},{26,0.045},{27,0.01}, {28,0.02},{29,0.022}},//非对非花非顺
 {{0,0},   {0,0.38},{0,0}, {0,0.4}, {0,0},   {26,0.12}, {27,0.005},{28,0.02},{29,0.085}},//对子
};

float SameFlush = 0.066;
float StraPer[5] = {0.01,0.028,0.045,0.06,0.075};

enum{
 AK = 0,P1,P2,U1,U2,Set,Stra,Flush,Full,
};

void get_CardPoint(int& pnt,char n);
void get_StraType(Cards_ppt& cards);
void get_Cards(Cards_ppt& cards);
void Cacl_CardsPer(Cards_ppt& cards,float& per);

int _tmain(int argc, _TCHAR* argv[])
{
 Cards_ppt cards;
 float per;
 while (1)
 {
  get_Cards(cards);
  Cacl_CardsPer(cards,per);
 }
 return 0;
}

void Cacl_CardsPer(Cards_ppt& cards,float& per)
{
 DT my_draw[9];
 float win[9],twin[9];

 for(int i=0; i<9; ++i)
  my_draw[i] = Draw_Per[cards.IsPair][i];

 my_draw[P1].Type = 1+cards.C1;
 my_draw[P2].Type = 1+cards.C2;
 my_draw[U1].Type = 13+cards.C1;
 my_draw[U2].Type = 13+cards.C2;
 if(my_draw[U1].Type < 14)
  my_draw[U1].Type = 14;
 if(my_draw[U2].Type < 14)
  my_draw[U2].Type = 14;

 if(cards.IsSame)
  my_draw[Flush].Per = SameFlush;
 if(!cards.IsPair)
  my_draw[Stra].Per = StraPer[cards.StraType];

 for(int i=0; i<9; ++i)
  twin[i] = win[i] = WIN[my_draw[i].Type];

 cout<<endl;
 for(int k=2; k<=9; ++k)
 {
  int val = 0;
  per = 0;
  for(int i=0; i<9; ++i)
  {
   per += my_draw[i].Per*twin[i];
   twin[i] *= win[i];
  }
  per *= 100;
  val = per * (k-1);
  cout<<" "<<k<<"人:"<<" 胜率 = "<<per<<", 价值 = "<<val<<endl;
 }

 cout<<"=======================================================================/n/n";
}

void get_CardPoint(int& pnt,char n)
{
 if(n=='A' || n=='a')
  pnt = 12;
 else if(n=='K' || n=='k')
  pnt = 11;
 else if(n=='Q' || n=='q')
  pnt = 10;
 else if(n=='J' || n=='j')
  pnt = 9;
 else if(n=='T' || n=='t')
  pnt = 8;
 else
  pnt = n - '2';
}

void get_StraType(Cards_ppt& cards)
{
 int h,l;
 h = cards.C1;
 l = cards.C2;

 if(h == l)
 {
  cards.StraType = 0;
  return;
 }
 else if(h < l)
 {
  int t = h;
  h = l;
  l = t;
 }

 if(h == 12)//A
 {
  if(h-l<=4 || h-l>=8)
   cards.StraType = 1;
  else
   cards.StraType = 0;
  return;
 }
 else
 {
  if(h-l > 4)
   cards.StraType = 0;
  else if(h-l == 4)
   cards.StraType = 1;
  else if(h-l == 3)
   cards.StraType = 2;
  else if(h-l == 2)
  {
   if(h==11 || l==0)// k||2
    cards.StraType = 2;
   else
    cards.StraType = 3;
  }
  else
  {
   if(h==11 || l==0)// k||2
    cards.StraType = 2;
   else if(h==10 || l==1)// Q||3
    cards.StraType = 3;
   else
    cards.StraType = 4;
  }
 }
}

void get_Cards(Cards_ppt& cards)
{
 char n1,f1,n2,f2;

 cout<<"Please input Cards: ";
 cin>>n1>>f1>>n2>>f2;

 cards.IsPair = (n1 == n2);
 cards.IsSame = (f1 == f2);
 get_CardPoint(cards.C1,n1);
 get_CardPoint(cards.C2,n2);
 get_StraType(cards);
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值