德州扑克【大小盲注、加、跟、弃】等规则详解 - 博乐德克萨斯扑克的日志,人人网,博乐德克萨斯扑克的公共主页
其实,2月14号是愚人节,4月1号才是情人节。2月14号多少人在用甜言蜜语骗着别人,4月1号又有多少男女以开玩笑为借口说出了真心话.
德州扑克【大小盲注、加、跟、弃】等规则详解
除大小王外的52张扑克牌。&
2-9人,2人即可开始游戏.
游戏模式&No Limit
No Limit是指每轮游戏过程中没有任何限制,所以No Limit模式是德克萨斯扑克是一种风险更大但更富挑战性刺激性的游戏模式。
第一盘游戏开始随机选定庄家,第2盘按照第1盘游戏的庄家顺时针选定庄家。&小盲位&小盲位是指由按照顺时针次序庄家的下一位玩家。游戏开始后,小盲位玩家获得系统自动发的牌,并由系统代该玩家自动下本房间最低额的一半。
大盲位是指由按照顺时针次序小盲位的下一位玩家。游戏开始后,大盲位玩家由系统代其自动下本房间最低额。
从小盲位的玩家开始发起,按照顺时针次序,每人每次一张,直接到所有人都有2张底牌为止。
在需要发牌前,按照游戏规则需要烧牌一张,即从剩余的牌中按次序拿出最上面一张废除,再继续发牌。
最开始发给玩家的两张牌叫做底牌,只允许玩家自己看到,并且以明牌的方式放置在玩家区域旁。&公共牌&将根据游戏的进行,在台面上摆放5张可以和底牌配套使用的牌叫做公共牌。&下&下是指之前的玩家没有进行过下的行为,此时该玩家可以按照自己的意愿率先下一定数量的筹码到游戏中。
跟&跟是指和前面玩家下同样数量的筹码。在之前的玩家没有下的基础上,下一位玩家的操作行为是只有下而没有跟。跟的时候只能看到需要跟的数值,无法更改数值,并且显示的数量是相对增量值,即还需要跟多少。如果玩家拥有的筹码数少于需要跟的值,则不能&跟&只能&全下&。&弃牌&放弃继续下去。
不做任何操作过牌到下一个人,并保留下的权利。过牌必须是在无需跟进的情况下使用,比如前面所有玩家都过牌或弃牌的情况。若前面的玩家一旦有人有下则不允许使用过牌。
在前面玩家下、跟、加的基础上,增加更多的筹码。当之前的玩家必须要有下或跟或加的基础上,下一位玩家的操作行为才能有&加&。但如果玩家拥有的筹码超过需要跟的值,不足以支撑到加的最低需要数值,那么不能&加&只能&全下&。
指的是把手上剩下的所有筹码一次全下。一个人在没有足够筹码跟的时候可以把仅剩的筹码全部下上。一旦有人全下,底池可能会分出一个&边池...
阅读(25059)|
人人移动客户端下载C++德州扑克的核心规则算法
投稿:hebedich
字体:[ ] 类型:转载 时间:
德州扑克想必很多人都玩过,当然对于新手需要说明的是,德州指的是德克萨斯州,而不是山东德州。分享下在计算最大牌型,比牌逻辑的算法和洗牌的方法,希望对大家有帮助。
自己编写,适用于windows,linux平台。
#include "public.h"
int TexasCombine5(unsigned char* pCard,
unsigned char* pCardColor, unsigned char** pCardResult, unsigned char** pColorResult)
int count = 0;
//这里为了速度,没用求组合的公式
if (pCard[6] == 0)//6张牌
count = 6;
*pCardResult = (unsigned char*)MyAlloc(30);
*pColorResult = (unsigned char*)MyAlloc(30);
*(*pCardResult + 0) = pCard[0];
*(*pColorResult + 0) = pCardColor[0];
*(*pCardResult + 1) = pCard[1];
*(*pColorResult + 1) = pCardColor[1];
*(*pCardResult + 2) = pCard[2];
*(*pColorResult + 2) = pCardColor[2];
*(*pCardResult + 3) = pCard[3];
*(*pColorResult + 3) = pCardColor[3];
*(*pCardResult + 4) = pCard[4];
*(*pColorResult + 4) = pCardColor[4];
*(*pCardResult + 5) = pCard[0];
*(*pColorResult + 5) = pCardColor[0];
*(*pCardResult + 6) = pCard[1];
*(*pColorResult + 6) = pCardColor[1];
*(*pCardResult + 7) = pCard[2];
*(*pColorResult + 7) = pCardColor[2];
*(*pCardResult + 8) = pCard[3];
*(*pColorResult + 8) = pCardColor[3];
*(*pCardResult + 9) = pCard[5];
*(*pColorResult + 9) = pCardColor[5];
*(*pCardResult + 10) = pCard[0];
*(*pColorResult + 10) = pCardColor[0];
*(*pCardResult + 11) = pCard[1];
*(*pColorResult + 11) = pCardColor[1];
*(*pCardResult + 12) = pCard[2];
*(*pColorResult + 12) = pCardColor[2];
*(*pCardResult + 13) = pCard[4];
*(*pColorResult + 13) = pCardColor[4];
*(*pCardResult + 14) = pCard[5];
*(*pColorResult + 14) = pCardColor[5];
*(*pCardResult + 15) = pCard[0];
*(*pColorResult + 15) = pCardColor[0];
*(*pCardResult + 16) = pCard[1];
*(*pColorResult + 16) = pCardColor[1];
*(*pCardResult + 17) = pCard[3];
*(*pColorResult + 17) = pCardColor[3];
*(*pCardResult + 18) = pCard[4];
*(*pColorResult + 18) = pCardColor[4];
*(*pCardResult + 19) = pCard[5];
*(*pColorResult + 19) = pCardColor[5];
*(*pCardResult + 20) = pCard[0];
*(*pColorResult + 20) = pCardColor[0];
*(*pCardResult + 21) = pCard[2];
*(*pColorResult + 21) = pCardColor[2];
*(*pCardResult + 22) = pCard[3];
*(*pColorResult + 22) = pCardColor[3];
*(*pCardResult + 23) = pCard[4];
*(*pColorResult + 23) = pCardColor[4];
*(*pCardResult + 24) = pCard[5];
*(*pColorResult + 24) = pCardColor[5];
*(*pCardResult + 25) = pCard[1];
*(*pColorResult + 25) = pCardColor[1];
*(*pCardResult + 26) = pCard[2];
*(*pColorResult + 26) = pCardColor[2];
*(*pCardResult + 27) = pCard[3];
*(*pColorResult + 27) = pCardColor[3];
*(*pCardResult + 28) = pCard[4];
*(*pColorResult + 28) = pCardColor[4];
*(*pCardResult + 29) = pCard[5];
*(*pColorResult + 29) = pCardColor[5];
count = 21;
*pCardResult = (unsigned char*)MyAlloc(105);
*pColorResult = (unsigned char*)MyAlloc(105);
*(*pCardResult + 0) = pCard[0];
*(*pColorResult + 0) = pCardColor[0];
*(*pCardResult + 1) = pCard[1];
*(*pColorResult + 1) = pCardColor[1];
*(*pCardResult + 2) = pCard[2];
*(*pColorResult + 2) = pCardColor[2];
*(*pCardResult + 3) = pCard[3];
*(*pColorResult + 3) = pCardColor[3];
*(*pCardResult + 4) = pCard[4];
*(*pColorResult + 4) = pCardColor[4];
*(*pCardResult + 5) = pCard[0];
*(*pColorResult + 5) = pCardColor[0];
*(*pCardResult + 6) = pCard[1];
*(*pColorResult + 6) = pCardColor[1];
*(*pCardResult + 7) = pCard[2];
*(*pColorResult + 7) = pCardColor[2];
*(*pCardResult + 8) = pCard[3];
*(*pColorResult + 8) = pCardColor[3];
*(*pCardResult + 9) = pCard[5];
*(*pColorResult + 9) = pCardColor[5];
*(*pCardResult + 10) = pCard[0];
*(*pColorResult + 10) = pCardColor[0];
*(*pCardResult + 11) = pCard[1];
*(*pColorResult + 11) = pCardColor[1];
*(*pCardResult + 12) = pCard[2];
*(*pColorResult + 12) = pCardColor[2];
*(*pCardResult + 13) = pCard[3];
*(*pColorResult + 13) = pCardColor[3];
*(*pCardResult + 14) = pCard[6];
*(*pColorResult + 14) = pCardColor[6];
*(*pCardResult + 15) = pCard[0];
*(*pColorResult + 15) = pCardColor[0];
*(*pCardResult + 16) = pCard[1];
*(*pColorResult + 16) = pCardColor[1];
*(*pCardResult + 17) = pCard[2];
*(*pColorResult + 17) = pCardColor[2];
*(*pCardResult + 18) = pCard[4];
*(*pColorResult + 18) = pCardColor[4];
*(*pCardResult + 19) = pCard[5];
*(*pColorResult + 19) = pCardColor[5];
*(*pCardResult + 20) = pCard[0];
*(*pColorResult + 20) = pCardColor[0];
*(*pCardResult + 21) = pCard[1];
*(*pColorResult + 21) = pCardColor[1];
*(*pCardResult + 22) = pCard[2];
*(*pColorResult + 22) = pCardColor[2];
*(*pCardResult + 23) = pCard[4];
*(*pColorResult + 23) = pCardColor[4];
*(*pCardResult + 24) = pCard[6];
*(*pColorResult + 24) = pCardColor[6];
*(*pCardResult + 25) = pCard[0];
*(*pColorResult + 25) = pCardColor[0];
*(*pCardResult + 26) = pCard[1];
*(*pColorResult + 26) = pCardColor[1];
*(*pCardResult + 27) = pCard[2];
*(*pColorResult + 27) = pCardColor[2];
*(*pCardResult + 28) = pCard[5];
*(*pColorResult + 28) = pCardColor[5];
*(*pCardResult + 29) = pCard[6];
*(*pColorResult + 29) = pCardColor[6];
*(*pCardResult + 30) = pCard[0];
*(*pColorResult + 30) = pCardColor[0];
*(*pCardResult + 31) = pCard[1];
*(*pColorResult + 31) = pCardColor[1];
*(*pCardResult + 32) = pCard[3];
*(*pColorResult + 32) = pCardColor[3];
*(*pCardResult + 33) = pCard[4];
*(*pColorResult + 33) = pCardColor[4];
*(*pCardResult + 34) = pCard[5];
*(*pColorResult + 34) = pCardColor[5];
*(*pCardResult + 35) = pCard[0];
*(*pColorResult + 35) = pCardColor[0];
*(*pCardResult + 36) = pCard[1];
*(*pColorResult + 36) = pCardColor[1];
*(*pCardResult + 37) = pCard[3];
*(*pColorResult + 37) = pCardColor[3];
*(*pCardResult + 38) = pCard[4];
*(*pColorResult + 38) = pCardColor[4];
*(*pCardResult + 39) = pCard[6];
*(*pColorResult + 39) = pCardColor[6];
*(*pCardResult + 40) = pCard[0];
*(*pColorResult + 40) = pCardColor[0];
*(*pCardResult + 41) = pCard[1];
*(*pColorResult + 41) = pCardColor[1];
*(*pCardResult + 42) = pCard[3];
*(*pColorResult + 42) = pCardColor[3];
*(*pCardResult + 43) = pCard[5];
*(*pColorResult + 43) = pCardColor[5];
*(*pCardResult + 44) = pCard[6];
*(*pColorResult + 44) = pCardColor[6];
*(*pCardResult + 45) = pCard[0];
*(*pColorResult + 45) = pCardColor[0];
*(*pCardResult + 46) = pCard[1];
*(*pColorResult + 46) = pCardColor[1];
*(*pCardResult + 47) = pCard[4];
*(*pColorResult + 47) = pCardColor[4];
*(*pCardResult + 48) = pCard[5];
*(*pColorResult + 48) = pCardColor[5];
*(*pCardResult + 49) = pCard[6];
*(*pColorResult + 49) = pCardColor[6];
*(*pCardResult + 50) = pCard[0];
*(*pColorResult + 50) = pCardColor[0];
*(*pCardResult + 51) = pCard[2];
*(*pColorResult + 51) = pCardColor[2];
*(*pCardResult + 52) = pCard[3];
*(*pColorResult + 52) = pCardColor[3];
*(*pCardResult + 53) = pCard[4];
*(*pColorResult + 53) = pCardColor[4];
*(*pCardResult + 54) = pCard[5];
*(*pColorResult + 54) = pCardColor[5];
*(*pCardResult + 55) = pCard[0];
*(*pColorResult + 55) = pCardColor[0];
*(*pCardResult + 56) = pCard[2];
*(*pColorResult + 56) = pCardColor[2];
*(*pCardResult + 57) = pCard[3];
*(*pColorResult + 57) = pCardColor[3];
*(*pCardResult + 58) = pCard[4];
*(*pColorResult + 58) = pCardColor[4];
*(*pCardResult + 59) = pCard[6];
*(*pColorResult + 59) = pCardColor[6];
*(*pCardResult + 60) = pCard[0];
*(*pColorResult + 60) = pCardColor[0];
*(*pCardResult + 61) = pCard[2];
*(*pColorResult + 61) = pCardColor[2];
*(*pCardResult + 62) = pCard[3];
*(*pColorResult + 62) = pCardColor[3];
*(*pCardResult + 63) = pCard[5];
*(*pColorResult + 63) = pCardColor[5];
*(*pCardResult + 64) = pCard[6];
*(*pColorResult + 64) = pCardColor[6];
*(*pCardResult + 65) = pCard[0];
*(*pColorResult + 65) = pCardColor[0];
*(*pCardResult + 66) = pCard[2];
*(*pColorResult + 66) = pCardColor[2];
*(*pCardResult + 67) = pCard[4];
*(*pColorResult + 67) = pCardColor[4];
*(*pCardResult + 68) = pCard[5];
*(*pColorResult + 68) = pCardColor[5];
*(*pCardResult + 69) = pCard[6];
*(*pColorResult + 69) = pCardColor[6];
*(*pCardResult + 70) = pCard[0];
*(*pColorResult + 70) = pCardColor[0];
*(*pCardResult + 71) = pCard[3];
*(*pColorResult + 71) = pCardColor[3];
*(*pCardResult + 72) = pCard[4];
*(*pColorResult + 72) = pCardColor[4];
*(*pCardResult + 73) = pCard[5];
*(*pColorResult + 73) = pCardColor[5];
*(*pCardResult + 74) = pCard[6];
*(*pColorResult + 74) = pCardColor[6];
*(*pCardResult + 75) = pCard[1];
*(*pColorResult + 75) = pCardColor[1];
*(*pCardResult + 76) = pCard[2];
*(*pColorResult + 76) = pCardColor[2];
*(*pCardResult + 77) = pCard[3];
*(*pColorResult + 77) = pCardColor[3];
*(*pCardResult + 78) = pCard[4];
*(*pColorResult + 78) = pCardColor[4];
*(*pCardResult + 79) = pCard[5];
*(*pColorResult + 79) = pCardColor[5];
*(*pCardResult + 80) = pCard[1];
*(*pColorResult + 80) = pCardColor[1];
*(*pCardResult + 81) = pCard[2];
*(*pColorResult + 81) = pCardColor[2];
*(*pCardResult + 82) = pCard[3];
*(*pColorResult + 82) = pCardColor[3];
*(*pCardResult + 83) = pCard[4];
*(*pColorResult + 83) = pCardColor[4];
*(*pCardResult + 84) = pCard[6];
*(*pColorResult + 84) = pCardColor[6];
*(*pCardResult + 85) = pCard[1];
*(*pColorResult + 85) = pCardColor[1];
*(*pCardResult + 86) = pCard[2];
*(*pColorResult + 86) = pCardColor[2];
*(*pCardResult + 87) = pCard[3];
*(*pColorResult + 87) = pCardColor[3];
*(*pCardResult + 88) = pCard[5];
*(*pColorResult + 88) = pCardColor[5];
*(*pCardResult + 89) = pCard[6];
*(*pColorResult + 89) = pCardColor[6];
*(*pCardResult + 90) = pCard[1];
*(*pColorResult + 90) = pCardColor[1];
*(*pCardResult + 91) = pCard[2];
*(*pColorResult + 91) = pCardColor[2];
*(*pCardResult + 92) = pCard[4];
*(*pColorResult + 92) = pCardColor[4];
*(*pCardResult + 93) = pCard[5];
*(*pColorResult + 93) = pCardColor[5];
*(*pCardResult + 94) = pCard[6];
*(*pColorResult + 94) = pCardColor[6];
*(*pCardResult + 95) = pCard[1];
*(*pColorResult + 95) = pCardColor[1];
*(*pCardResult + 96) = pCard[3];
*(*pColorResult + 96) = pCardColor[3];
*(*pCardResult + 97) = pCard[4];
*(*pColorResult + 97) = pCardColor[4];
*(*pCardResult + 98) = pCard[5];
*(*pColorResult + 98) = pCardColor[5];
*(*pCardResult + 99) = pCard[6];
*(*pColorResult + 99) = pCardColor[6];
*(*pCardResult + 100) = pCard[2];
*(*pColorResult + 100) = pCardColor[2];
*(*pCardResult + 101) = pCard[3];
*(*pColorResult + 101) = pCardColor[3];
*(*pCardResult + 102) = pCard[4];
*(*pColorResult + 102) = pCardColor[4];
*(*pCardResult + 103) = pCard[5];
*(*pColorResult + 103) = pCardColor[5];
*(*pCardResult + 104) = pCard[6];
*(*pColorResult + 104) = pCardColor[6];
void CardSort(unsigned char* p, unsigned char* p2, int pCount)
for (i = 0; i & pCount - 1; ++i)
for (j = i + 1; j & pC ++j)
if (p[i] & p[j])
p[i] = p[j];
c = p2[i];
p2[i] = p2[j];
//对于高牌,从左起第4位,分别返回五张牌从大到小的牌点值,如:0x000DA932表示 A,J,10,4,3
//注:对于牌张不足5张的高牌,从左起第4位,分别返回从大到小的牌点值,无牌的位置填0,如:0x000DA000表示 A,J
//对于1对,在左起第4位返回牌点值,如:0x000D9870.表示A一对, 8, 7, 6
//对于2对,在左起第4,5位返回牌点值,如:0x000D9C00.表示A一对,10一对, Q
//对于3条,在左起第4位返回牌点值,如:0x,表示三条3,A,10
//对于顺子,在左起第4位返回顺子的最大牌点值,如:0x000C0000,表示K,Q,J,10,9,8
//对于同花,从左起第4位,分别返回五张牌从大到小的牌点值,如:0x000DA932表示 A,J,10,4,3
//对于葫芦,从左起第4,5位返回牌点值,如:0x000DA000表示 A,A,A,J,J
//对于金刚,在左起第4位返回牌点值,如:0x000DA000.表示A金刚,J
//对于同花顺,在左起第4位返回牌点值,如:0x,表示98765的同花顺
void TexasCalcLevel(unsigned char *card, unsigned char *cardColor, LPCARD_LEVEL pResult)
if (card[2] == 0)//两张牌
if (card[0] == card[1])//一对
pResult-&detail = card[0] && 16;
pResult-&level = TEXAS_CARD_LEVEL_PAIR;
else//高牌
pResult-&detail = (card[0] && 16) + (card[1] && 12);
pResult-&level = TEXAS_CARD_LEVEL_HIGH;
else if (card[3] == 0)//三张牌
//可能是高牌,一对,三条
if (card[0] == card[1] && card[1] == card[2])//三条
pResult-&detail = card[0] && 16;
pResult-&level = TEXAS_CARD_LEVEL_ARTICLE_3;
else if (card[0] == card[1] || card[0] == card[2])//一对
pResult-&detail = (card[0] && 16) + (card[2] && 12);
pResult-&level = TEXAS_CARD_LEVEL_PAIR;
else if (card[1] == card[2])//一对
pResult-&detail = (card[1] && 16) + (card[2] && 12);
pResult-&level = TEXAS_CARD_LEVEL_PAIR;
else//高牌
pResult-&detail = (card[0] && 16) + (card[1] && 12) + (card[2] && 8);
pResult-&level = TEXAS_CARD_LEVEL_HIGH;
else if (card[4] == 0)//四张牌
//可能是金刚,高牌, 一对,两对,三条
if (card[0] == card[1] && card[1] == card[2] && card[2] == card[3])//金刚
pResult-&detail = card[0] && 16;
pResult-&level = TEXAS_CARD_LEVEL_ARTICLE_4;
if (card[2] == card[3] && card[1] == card[2])//三条
pResult-&detail = (card[1] && 16) + (card[3] && 12);
pResult-&level = TEXAS_CARD_LEVEL_ARTICLE_3;
else if (card[0] == card[1] && card[1] == card[2])//三条
pResult-&detail = (card[0] && 16) + (card[3] && 12);
pResult-&level = TEXAS_CARD_LEVEL_ARTICLE_3;
else if (card[0] == card[1] && card[2] == card[3])//两对
pResult-&detail = (card[0] && 16) + (card[2] && 12);
pResult-&level = TEXAS_CARD_LEVEL_TWO_PAIR;
else if (card[0] == card[1] || card[1] == card[2])//一对
pResult-&detail = (card[1] && 16) + (card[1] && 12) + (card[3] && 8);
pResult-&level = TEXAS_CARD_LEVEL_PAIR;
else if (card[2] == card[3])//一对
pResult-&detail = (card[2] && 16) + (card[0] && 12) + (card[3] && 8);
pResult-&level = TEXAS_CARD_LEVEL_PAIR;
else//高牌
pResult-&detail = (card[0] && 16) + (card[1] && 12) + (card[2] && 8) + (card[3] && 4);
pResult-&level = TEXAS_CARD_LEVEL_HIGH;
else //五张牌
if (card[0] == card[1] && card[1] == card[2] && card[2] == card[3])//金刚
pResult-&detail = (card[1] && 16) + (card[4] && 12);
pResult-&level = TEXAS_CARD_LEVEL_ARTICLE_4;
else if (card[4] == card[1] && card[1] == card[2] && card[2] == card[3])//金刚
pResult-&detail = (card[1] && 16) + (card[0] && 12);
pResult-&level = TEXAS_CARD_LEVEL_ARTICLE_4;
else if (card[0] == card[1] && card[1] == card[2] && card[3] == card[4])//葫芦
pResult-&detail = (card[0] && 16) + (card[3] && 12);
pResult-&level = TEXAS_CARD_LEVEL_FULL_HOUSE;
else if (card[0] == card[1] && card[2] == card[3] && card[3] == card[4])//葫芦
pResult-&detail = (card[2] && 16) + (card[0] && 12);
pResult-&level = TEXAS_CARD_LEVEL_FULL_HOUSE;
else if ((card[0] - card[1] == 1 || card[0] - card[4] == 12)
&& card[1] - card[2] == 1
&& card[2] - card[3] == 1
&& card[3] - card[4] == 1
)//同花顺或者顺子
if (cardColor[0] == cardColor[1]
&& cardColor[0] == cardColor[2]
&& cardColor[0] == cardColor[3]
&& cardColor[0] == cardColor[4]
if (card[0] == 0x0D)//12345小于23456,所以12345中最大的是5
pResult-&detail = card[1] && 16;
pResult-&level = TEXAS_CARD_LEVEL_STRAIGHT_FLUSH;
pResult-&detail = card[0] && 16;
pResult-&level = TEXAS_CARD_LEVEL_STRAIGHT_FLUSH;
else//顺子
pResult-&level = TEXAS_CARD_LEVEL_STRAIGHT;
if (card[0] == 0x0D)//12345小于23456,所以12345中最大的是5
pResult-&detail = card[1] && 16;
pResult-&detail = card[0] && 16;
else if (cardColor[0] == cardColor[1]
&& cardColor[0] == cardColor[2]
&& cardColor[0] == cardColor[3]
&& cardColor[0] == cardColor[4]
)//同花或者同花顺
pResult-&detail = 0;
if (card[0] - card[1] == 1
&& card[1] - card[2] == 1
&& card[2] - card[3] == 1
&& card[3] - card[4] == 1
if (card[0] == 0x0D)//12345小于23456,所以12345中最大的是5
pResult-&detail = card[1] && 16;
pResult-&level = TEXAS_CARD_LEVEL_STRAIGHT_FLUSH;
pResult-&detail = card[0] && 16;
pResult-&level = TEXAS_CARD_LEVEL_STRAIGHT_FLUSH;
else//同花
pResult-&detail = ((card[0] && 16) + (card[1] && 12) + (card[2] && 8) + (card[3] && 4) + card[4]);
pResult-&level = TEXAS_CARD_LEVEL_FLUSH;
else //三条,两队,一对,高牌
if (card[0] == card[1] && card[1] == card[2])//三条
pResult-&detail = (card[2] && 16) + (card[3] && 12) + (card[4] && 8);
pResult-&level = TEXAS_CARD_LEVEL_ARTICLE_3;
else if (card[1] == card[2] && card[2] == card[3])//三条
pResult-&detail = (card[2] && 16) + (card[0] && 12) + (card[4] && 8);
pResult-&level = TEXAS_CARD_LEVEL_ARTICLE_3;
else if (card[2] == card[3] && card[3] == card[4])//三条
pResult-&detail = (card[2] && 16) + (card[0] && 12) + (card[1] && 8);
pResult-&level = TEXAS_CARD_LEVEL_ARTICLE_3;
else if (card[0] == card[1] && card[2] == card[3])//两对
pResult-&detail = (card[0] && 16) + (card[2] && 12) + (card[4] && 8);
pResult-&level = TEXAS_CARD_LEVEL_TWO_PAIR;
else if (card[0] == card[1] && card[3] == card[4])//两对
pResult-&detail = (card[0] && 16) + (card[3] && 12) + (card[2] && 8);
pResult-&level = TEXAS_CARD_LEVEL_TWO_PAIR;
else if (card[1] == card[2] && card[3] == card[4])//两对
pResult-&detail = (card[1] && 16) + (card[3] && 12) + (card[0] && 8);
pResult-&level = TEXAS_CARD_LEVEL_TWO_PAIR;
else if (card[0] == card[1])//一对
pResult-&detail = (card[0] && 16) + (card[2] && 12) + (card[3] && 8) + (card[4] && 4);
pResult-&level = TEXAS_CARD_LEVEL_PAIR;
else if (card[1] == card[2])//一对
pResult-&detail = (card[1] && 16) + (card[0] && 12) + (card[3] && 8) + (card[4] && 4);
pResult-&level = TEXAS_CARD_LEVEL_PAIR;
else if (card[2] == card[3])//一对
pResult-&detail = (card[2] && 16) + (card[0] && 12) + (card[1] && 8) + (card[4] && 4);
pResult-&level = TEXAS_CARD_LEVEL_PAIR;
else if (card[3] == card[4])//一对
pResult-&detail = (card[3] && 16) + (card[0] && 12) + (card[1] && 8) + (card[2] && 4);
pResult-&level = TEXAS_CARD_LEVEL_PAIR;
else//高牌
pResult-&detail = (card[0] && 16) + (card[1] && 12) + (card[2] && 8) + (card[3] && 4) + card[4];
pResult-&level = TEXAS_CARD_LEVEL_HIGH;
//参数值:0表示为空牌,c1,c2是玩家手上的牌,其它是公共牌,公共牌允许为空牌,但所有空牌必须放在最后
//返回值:如果牌张数小于2,则返回0,否则返回1
int TexasCalcLevelEx(unsigned char c1, unsigned char c2,
unsigned char c3, unsigned char c4, unsigned char c5, unsigned char c6, unsigned char c7
, LPCARD_LEVEL pResult)
unsigned char card[7];
unsigned char cardColor[7];
if (c1 == 0 || c2 == 0)//c1,c2原则上不能为空牌
//得到全部的牌点
card[0] = c1 & 0x0F;
card[1] = c2 & 0x0F;
card[2] = c3 & 0x0F;
card[3] = c4 & 0x0F;
card[4] = c5 & 0x0F;
card[5] = c6 & 0x0F;
card[6] = c7 & 0x0F;
//得到全部的牌颜色
cardColor[0] = c1 && 4;
cardColor[1] = c2 && 4;
cardColor[2] = c3 && 4;
cardColor[3] = c4 && 4;
cardColor[4] = c5 && 4;
cardColor[5] = c6 && 4;
cardColor[6] = c7 && 4;
CardSort(card, cardColor, 7);
if (card[5]) //六张牌或者七张牌
unsigned char *allCardCombR
unsigned char *allCardCombResultC
//先获取全部的5张牌组合
int cardCombCount = TexasCombine5(card, cardColor, &allCardCombResult, &allCardCombResultColor);
CARD_LEVEL cardL
pResult-&detail = pResult-&level = 0;
//逐个组合计算等级,并取最大值
for (i = 0; i & cardCombC ++i)
TexasCalcLevel(allCardCombResult + i * 5, allCardCombResultColor + i * 5, &cardLevel);
////打印中间结果
//char buff[32];
//allCardCombResult[i * 5] += allCardCombResultColor[i * 5] && 4;
//allCardCombResult[i * 5+1] += allCardCombResultColor[i * 5+1] && 4;
//allCardCombResult[i * 5+2] += allCardCombResultColor[i * 5+2] && 4;
//allCardCombResult[i * 5+3] += allCardCombResultColor[i * 5+3] && 4;
//allCardCombResult[i * 5+4] += allCardCombResultColor[i * 5+4] && 4;
//GLog("%s %s,%s,%s,%s,%s\r\n", TexasGetCardLevelDesc(&cardLevel, buff)
// ,CardGetName(allCardCombResult[i * 5])
// ,CardGetName(allCardCombResult[i * 5+1])
// ,CardGetName(allCardCombResult[i * 5+2])
// ,CardGetName(allCardCombResult[i * 5+3])
// ,CardGetName(allCardCombResult[i * 5+4])
if (cardLevel.level & pResult-&level || cardLevel.level == pResult-&level && cardLevel.detail &= pResult-&detail)
pResult-&level = cardLevel.
pResult-&detail = cardLevel.
MyFree(allCardCombResult);
MyFree(allCardCombResultColor);
TexasCalcLevel(card, cardColor, pResult);
//获取牌级描述,pBuffer必须先分配好足够空间,至少24字节
char* TexasGetCardLevelDesc(LPCARD_LEVEL pCardLevel, char* pBuffer)
switch (pCardLevel-&level)
case TEXAS_CARD_LEVEL_HIGH:
sprintf(pBuffer, "高牌:%s,%s,%s,%s,%s"
, CardGetCardPointName((pCardLevel-&detail && 16) & 0xF)
, CardGetCardPointName((pCardLevel-&detail && 12) & 0xF)
, CardGetCardPointName((pCardLevel-&detail && 8) & 0xF)
, CardGetCardPointName((pCardLevel-&detail && 4) & 0xF)
, CardGetCardPointName((pCardLevel-&detail && 0) & 0xF)
case TEXAS_CARD_LEVEL_PAIR:
sprintf(pBuffer, "一对:%s,(%s,%s,%s)"
, CardGetCardPointName((pCardLevel-&detail && 16) & 0xF)
, CardGetCardPointName((pCardLevel-&detail && 12) & 0xF)
, CardGetCardPointName((pCardLevel-&detail && 8) & 0xF)
, CardGetCardPointName((pCardLevel-&detail && 4) & 0xF)
case TEXAS_CARD_LEVEL_TWO_PAIR:
sprintf(pBuffer, "两对:%s,%s,(%s)"
, CardGetCardPointName((pCardLevel-&detail && 16) & 0xF)
, CardGetCardPointName((pCardLevel-&detail && 12) & 0xF)
, CardGetCardPointName((pCardLevel-&detail && 8) & 0xF)
case TEXAS_CARD_LEVEL_ARTICLE_3:
sprintf(pBuffer, "三条:%s,(%s,%s)"
, CardGetCardPointName((pCardLevel-&detail && 16) & 0xF)
, CardGetCardPointName((pCardLevel-&detail && 12) & 0xF)
, CardGetCardPointName((pCardLevel-&detail && 8) & 0xF)
case TEXAS_CARD_LEVEL_STRAIGHT:
sprintf(pBuffer, "顺子:%s"
, CardGetCardPointName((pCardLevel-&detail && 16) & 0xF)
case TEXAS_CARD_LEVEL_FLUSH:
sprintf(pBuffer, "同花:%s,%s,%s,%s,%s"
, CardGetCardPointName((pCardLevel-&detail && 16) & 0xF)
, CardGetCardPointName((pCardLevel-&detail && 12) & 0xF)
, CardGetCardPointName((pCardLevel-&detail && 8) & 0xF)
, CardGetCardPointName((pCardLevel-&detail && 4) & 0xF)
, CardGetCardPointName((pCardLevel-&detail && 0) & 0xF)
case TEXAS_CARD_LEVEL_FULL_HOUSE:
sprintf(pBuffer, "葫芦:%s,%s"
, CardGetCardPointName((pCardLevel-&detail && 16) & 0xF)
, CardGetCardPointName((pCardLevel-&detail && 12) & 0xF)
case TEXAS_CARD_LEVEL_ARTICLE_4:
sprintf(pBuffer, "金刚:%s,(%s)"
, CardGetCardPointName((pCardLevel-&detail && 16) & 0xF)
, CardGetCardPointName((pCardLevel-&detail && 12) & 0xF)
case TEXAS_CARD_LEVEL_STRAIGHT_FLUSH:
sprintf(pBuffer, "同花顺:%s"
, CardGetCardPointName((pCardLevel-&detail && 16) & 0xF)
strcpy(pBuffer, "未知");
GLog("TexasGetCardLevelDesc--%s\r\n", pBuffer);
您可能感兴趣的文章:
大家感兴趣的内容
12345678910
最近更新的内容
常用在线小工具