本文介绍了试图获得更精确的数字(Poker Hands Generator)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 Hello Everyone, 我用Java做了扑克计划,从根本上发现了随机创建的扑克牌的实力。我的程序运行正常...但我很确定它可以进行优化。 这是我100万手的结果: 产生的手数:1000000 同花顺:0.0012%理论上:0.0012% 四种:0.017%理论上:0.0240% 满屋:0.1535%理论:0.1441% 冲洗:0.2285%理论上:0.1967% 直: 0.3104%理论上:0.3532% 三种类型:2.2372%理论上:2.1128% Deux对:4.6104%理论上:4.759% 对:41.777%理论上:42.2569% 无:50.6648%理论上:50.157% 我的结果和理论。我一开始以为是因为我没有用足够的手。 这是我的结果,有5000万手: 产生的手数:50000000 同花顺:0.0012%理论上:0.0012% 四种类型:0.0183%理论上: 0.0240% 满屋:0.1489%理论:0.1441% 冲洗:0.2286%理论上:0.1967% 直:0.3086%In理论:0.3532% 三种类型:2.2266%理论上:2.1128% Deux对:4.6107%理论上:4.759% 对:41.7652%理论上:42.2569% 无:50.6918%理论上:50.1570% 再次,数字几乎相同所以它意味着我的逻辑存在缺陷。问题是我找不到那些缺陷。我的问题将是关于我的isFourOfAKind()方法,因为我得到的近似值减少了20%,然后是理论。我认为差别很大。 一般来说,我的程序是这样构建的 卡 - >西装,实力。 手 - > Card1,Card2,Card3,Card4,Card5。 这是我方法的表示(Card1 = Card1的强项。实际上Card1将被Card1.getCardStrenght()取代) if(Card1 == Card2&& Card1 == Card3&& Card1 == Card4&& Card1!= Card5) 返回true else if(Card1 == Card2&& Card1 == Card3&& Card1!= Card4&& Card1 == Card5) 返回true if(Card1 == Card2&& Card1!= Card3&& Card1 == Card4&& Card1 == Card5) 返回true if(Card1!= Card2&& Card1 == Card3&& Card1 == Card4&& Card1 == Card5) return真的 其他 返回false 我很确定这个逻辑是好的。问题是我的结果告诉我,我的逻辑不好。这种方法的缺陷在哪里? 先谢谢你,原谅我的英语错误......这不是我的第一语言 kinghippo423 PS我看到很多像老鼠一样的扑克手发生器比我的速度更快。是否有任何网站可以解释某些技术要求更快的技术。程序?很难等待1分钟,产生100万手...我希望我解释得很好。Hello Everyone, I did a poker program in Java that essencially finds the strenght of a poker hand created Randomly. My program is doing OK...but I''m pretty sure it can be optimised. This is my results with 1 million hands: Number of hands generated : 1000000 Straight Flush : 0.0012 % In theory : 0.0012%Four Of A Kind : 0.017 % In theory : 0.0240%Full House : 0.1535 % In theory : 0.1441%Flush : 0.2285 % In theory : 0.1967%Straight : 0.3104 % In theory : 0.3532%Three Of A Kind : 2.2372 % In theory : 2.1128%Deux Pairs : 4.6104 % In theory : 4.759%Pair : 41.777 % In theory : 42.2569%Nothing : 50.6648 % In theory : 50.157% There is big differences between my results and the theory. I thought at first that it was because I didn''t used enough hands. This is my results with 50 million hands: Number of hands generated : 50000000Straight Flush : 0.0012 % In theory : 0.0012%Four Of A Kind : 0.0183 % In theory : 0.0240%Full House : 0.1489 % In theory : 0.1441%Flush : 0.2286 % In theory : 0.1967%Straight : 0.3086 % In theory : 0.3532%Three Of A Kind : 2.2266 % In theory : 2.1128%Deux Pairs : 4.6107 % In theory : 4.759%Pair : 41.7652 % In theory : 42.2569%Nothing : 50.6918 % In theory : 50.1570% And again, the numbers are pretty much the same so it means that thereare flaws in my logic. The problem is I can''t find those flaws. My question will be about my isFourOfAKind() method because I get approximalety 20% less Four Of A Kind hands then the theory. A pretty good difference in my opinion. In general, my program is built like this Card --> suit, strenght.Hand --> Card1, Card2, Card3, Card4, Card5. This is a representation of my method (Card1 = the strenght of Card1. In reality Card1 would be replace by Card1.getCardStrenght()) if(Card1 == Card2 && Card1 == Card3 && Card1 == Card4 && Card1 != Card5)return trueelse if(Card1 == Card2 && Card1 == Card3 && Card1 != Card4 && Card1 == Card5)return trueif(Card1 == Card2 && Card1 != Card3 && Card1 == Card4 && Card1 == Card5)return trueif(Card1 != Card2 && Card1 == Card3 && Card1 == Card4 && Card1 == Card5)return trueelsereturn false I''m pretty sure this logic is good. The problem is my results tells me that my logic is NOT good. Where is the flaw in that method? Thanks in advance and pardon me for English mistakes...it isn''t my first language kinghippo423 P.S. I saw lots of poker hands generator like mice that works WAY faster than mine. Is there any website that explain some technics to have a "faster" program? It sucks to wait 1 minute ot generate 1 million hands...I hope I explain that well.推荐答案 展开 | 选择 | Wrap | 行号 这篇关于试图获得更精确的数字(Poker Hands Generator)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-27 00:07