德州扑克工具

THPoker的Python项目详细描述


德州扑克工具

安装

pip install THPoker

要求

  • python 3.6或更高版本

用法

核心

core是主要的项目模块,它包含与德州扑克一起工作的基本功能

Since 1.1.0 version there isn't Card and Deck in THPoker core, they uses from AGStuff.

卡(卡串=无,卡=无)

几张牌(7张或更少)。

Since 1.1.0 version base on AGStuff Cards.

表格(卡片字符串=无,卡片=无)

桌上有几张卡片

表格与卡片相同,只是表格中不能包含超过5个项目

手牌(卡片字符串=无,卡片=无)

玩家的手牌

手和卡片是一样的,除了手可以包含不超过2个项目和它有额外的属性(手的类型和手是否是一对)

>>>fromthpoker.coreimportHand>>>hand1=Hand("Ad/Js")>>>hand1.type'AJo'>>>hand1.is_pairFalse>>>hand2=Hand("7c/Tc")>>>hand2.type'T7s'>>>hand2.is_pairFalse>>>hand3=Hand("2s/2h")>>>hand3.type'22'>>>hand3.is_pairTrue

组合键(卡片字符串=无,卡片=无,表格=无,手=无,标称检查=假)

卡片组合。

有9种组合:Combo.HIGH_CARDCombo.ONE_PAIRCombo.TWO_PAIRSCombo.THREE_OF_A_KINDCombo.STRAIGHTCombo.FLUSHCombo.FULL_HOUSECombo.FOUR_OF_A_KINDCombo.STRAIGHT_FLUSH

组合键可以由卡片字符串设置

>>>fromthpoker.coreimportCombo>>>combo=Combo(cards_string="8h/9h/Th/Jh/Qh/Kh/Ah")>>>combo.type9>>>combo.type==Combo.STRAIGHT_FLUSHTrue>>>combo.cards[A,K,Q,J,T]>>>combo.name'straight flush'>>>combo[9,A,K,Q,J,T]>>>print(combo)straightflush(A,K,Q,J,T)

还可以通过卡设置组合键

>>>fromthpoker.coreimportCards,Combo>>>cards=Cards("3d/8c/Kh/8s/3h/Js/8h")>>>combo=Combo(cards=cards)>>>print(combo)fullhouse(8,8,8,3,3)

也可以通过表和手来设置组合键

>>>fromthpoker.coreimportTable,Hand,Combo>>>table=Table("Ts/5c/Ac/Kd/5h")>>>hand=Hand("Qh/5s")>>>combo=Combo(table=table,hand=hand)>>>print(combo)threeofakind(5,5,5,A,K)

可以比较C ombo

>>>fromthpoker.coreimportCombo>>>combo1=Combo(cards_string="8h/2c/Jd/Jh/5s/Kh/5c")>>>print(combo1)twopairs(J,J,5,5,K)>>>combo2=Combo(cards_string="9d/As/3c/9h/Qs/9s/9c")>>>print(combo2)fourofakind(9,9,9,9,A)>>>combo1>combo2False>>>combo1<combo2True>>>combo1!=combo2True>>>combo1==combo2False>>>combo3=Combo(cards_string="Qd/6d/9d/Kd/2d/8c/7d")>>>print(combo3)flush(K,Q,9,7,6)>>>combo4=Combo(cards_string="Qd/6d/9d/Kd/2d/6s/6h")>>>print(combo4)flush(K,Q,9,6,2)>>>combo3>combo4True>>>combo3<combo4False>>>combo3!=combo4True>>>combo3==combo4False>>>combo5=Combo(cards_string="4s/3c/8d/Kd/8s/8h/3d")>>>print(combo5)fullhouse(8,8,8,3,3)>>>combo6=Combo(cards_string="4s/3c/8d/Kd/8s/3s/8c")>>>print(combo6)fullhouse(8,8,8,3,3)>>>combo5>combo6False>>>combo5<combo6False>>>combo5!=combo6False>>>combo5==combo6True

有机会检查组合基本卡是否包含手牌

>>>fromthpoker.coreimportTable,Hand,Combo>>>table1=Table("7d/Ts/4d/8c/6h")>>>hand1=Hand("Ad/9c")>>>combo1=Combo(table=table1,hand=hand1,nominal_check=True)>>>print(combo1)straight(T,9,8,7,6)>>>combo1.is_realTrue>>>combo1.is_nominalFalse>>># combo base cards are (T♠, 9♣, 8♣, 7♦, 6♥)>>>table2=Table("8h/3c/8c/6d/5s")>>>hand2=Hand("Qc/Jc")>>>combo2=Combo(table=table2,hand=hand2,nominal_check=True)>>>print(combo2)onepair(8,8,Q,J,6)>>>combo2.is_realFalse>>>combo2.is_nominalTrue>>># combo base cards are (8♥, 8♣)

全套和两对(组合基本卡由两部分组成)可以是标称值的一半

>>>fromthpoker.coreimportTable,Hand,Combo>>>table1=Table("Th/6c/5h/Qh/5d")>>>hand1=Hand("Qd/Qs")>>>combo1=Combo(table=table1,hand=hand1,nominal_check=True)>>>print(combo1)fullhouse(Q,Q,Q,5,5)>>>combo1.is_half_nominalTrue>>># combo base cards are (Q♥, Q♠, Q♦) and (5♥, 5♦)>>>table2=Table("Kd/7s/Th/Ts/Jd")>>>hand2=Hand("2h/Kh")>>>combo2=Combo(table=table2,hand=hand2,nominal_check=True)>>>print(combo2)twopairs(K,K,T,T,J)>>>combo1.is_half_nominalTrue>>># combo base cards are (K♦, K♥) and (T♥, T♠)

核心

hardcore是一个项目模块,它允许您比core模块更快地找到一个组合,但是hardcore并不像core那么友好。由于1.1.0版的核心模块基于CTHPoker模块,wich基于c.

hcard(符号)

一些卡来自标准的52张牌组。

符号与AGStuff中的cards.core.Card符号相同。

>>>fromthpoker.hardcoreimporthcard>>>card=hcard("5s")>>>card54

硬核卡是一个数字。

体重数:20(2),30(3),40(4),50(5),60(6),70(7),80(8),90(9),100(10),110(杰克),120(女王),130(国王),140(4),50(5),^{>}(6),^{>}(7),70(7),80(cd25>}(ace)。

西装号码:1(梅花),2(钻石),3(红心),4(黑桃)。

>>>fromthpoker.hardcoreimporthcard>>>card=hcard("Qd")>>>isinstance(card,int)True>>>card==122True

hdeck()

标准52张牌组。

>>>fromthpoker.hardcoreimporthdeck>>>deck=hdeck()>>>deck[21,22,23,24,31,32,33,34,41,42,43,44,51,52,53,54,61,62,63,64,71,72,73,74,81,82,83,84,91,92,93,94,101,102,103,104,111,112,113,114,121,122,123,124,131,132,133,134,141,142,143,144]>>>isinstance(deck,list)True

hcards(卡片串,在手=0)

几张牌。

>>>fromthpoker.hardcoreimporthcards>>>cards=hcards("7s/Td/3h/Kd/5c")>>>cards[74,102,33,132,51]>>>isinstance(cards,list)True

卡可以设置为玩家的手牌

>>>fromthpoker.hardcoreimporthcards>>>cards=hcards("Js/Qs",in_hand=1)>>>cards[1114,1124]>>># hand cards are more than usual cards in a thousand

hcombo(卡串)

由卡片字符串设置的卡片组合

共有9种硬核组合:1(高卡),2(一对),3(两对),4(三种),5(直卡),6(平卡),7(全套),8(四种),9(直卡)。

>>>fromthpoker.hardcoreimporthcombo>>>combo1=hcombo("Tc/9c/8c/7c/6c")>>>combo1[9,10]>>># 1st number mean it is straight flush...# 2nd number mean the highest straight flush card is "ten">>>combo2=hcombo("4d/Js/4s/8d/4h")>>>combo2[4,4,11,8]>>># 1st number mean it is three of a kind...# 2nd number mean it is three of "fours"...# 3nd and 4th numbers mean additional cards ("jack" and "eight")>>>combo1>combo2True>>>combo1<combo2False>>>combo1!=combo2True>>>combo1==combo2False

chcombo(卡)

按卡设置的卡组合

>>>fromthpoker.hardcoreimporthcards,chcombo>>>combo1=chcombo(hcards("Qs/2h/9s/6s/Ad"))>>>combo1[1,14,12,9,6,2]>>># 1st number mean it is high card...# other numbers mean combination cards>>>combo2=chcombo(hcards("Jd/3d/7d/Kd/5d"))>>>combo2[6,13,11,7,5,3]>>># 1st number mean it is flush...# other numbers mean combination cards>>>combo1>combo2False>>>combo1<combo2True>>>combo1!=combo2True>>>combo1==combo2False

右组合(卡)

桌上和手上的卡片组合。还显示表示组合是否真实的组合比率

>>>fromthpoker.hardcoreimporthcards,rhcombo>>>combo1,ratio1=rhcombo(table=hcards("7d/Js/3d/7c/7h"),hand=hcards("7s/8s",in_hand=1))>>>combo1[8,7,11]>>>ratio12>>># 1st combo number mean it is four of a kind...# 2nd combo number mean it is four of a "seven"...# 3rd combo number mean additional combo card is "jack"...# ratio mean it is real combo>>>combo2,ratio2=rhcombo(table=hcards("5h/Qc/8d/Ts/5d"),hand=hcards("Tc/Kh",in_hand=1))>>>combo2[3,10,5,13]>>>ratio21>>># 1st combo number mean that it is two pairs...# 2nd combo number mean that 1st pair is pair of "ten"...# 3rd combo number mean that 2nd pair is pair of "five"...# 4th combo number mean that additional combination card is "king"...# ratio mean it is half nominal combo>>>combo3,ratio3=rhcombo(table=hcards("Ad/2s/3c/4c/5h"),hand=hcards("Ts/Tc",in_hand=1))>>>combo3[5,5]>>>ratio30>>># 1st combo number mean that it is straight...# 2nd combo number mean that the highest straight card is "five"...# ratio mean it is nominal combo

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java Android Action_Edit Intent无法像以前一样调用App Gallery来编辑图片   确保JRE兼容性的java适当程序(32或64位)   java JSONArray。for循环中的add(JSONObject)正在替换for循环中的旧值,数组由循环中的最后一个值组成   java需要帮助创建一个返回数组的方法,该数组的元素是另一个数组的平方   使用SmbFile w/groovy XmlSluper()创建xml。解析()Java   检查大小后的java ArrayIndexOutOfBoundsException   乘法表中的第k个最小元素   java 401 on请求,其中指定了'permitAll()'   java如何附加ORC文件   java hibernate类模型   java IDEA没有看到由自定义注释处理器生成的方法   Servlet中未声明java SerialVersionId   java linkedlist到达列表末尾时   java如何正确对齐EditText光标?   java 6编译器1.6上的eclipse重写方法错误   java如何在基于Jersey的RESTful Web服务中读取post数据   java如何在活动中正确使用接口?   Java的JIT编译器的工作速度有多快?