在 cribbage 中找到一条直线 [英] Finding a straight in a cribbage

查看:14
本文介绍了在 cribbage 中找到一条直线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于那些不熟悉 Cribbage 的人,它使用标准的 52 张纸牌,A 总是低.一个玩家的手牌由 4 张牌组成,并且有 1 张转牌可供所有玩家用来帮助他们的手牌得分.

For those of you not familiar with Cribbage, it uses a standard 52 card deck with aces being always low. A player's hand consists of 4 cards, and there is 1 turn card that all players can use to help score their hand.

所以为了给自己做一个小练习题,我写了一些 VBA 并将所有大约 1290 万个可能的评分组合打印在一个 Excel 表中.我为每张牌分配了一个 1 到 52 的整数,并将其设置为每个花色都是 13 张牌的连续块.1-13 = 梅花,14-26 = 钻石,27-39 = 红心,40-52 = 黑桃.我将每张牌都分配到相邻列中的单独单元格中.即 B1:E1 是手牌,F1 是转牌.手牌(B1:E1)也被组织在最低的卡号(不是卡值)在左边,最高的在右边.

So for a little practice problem for myself, I wrote a we bit of VBA and had all ~12.9 million possible scoring combination printed in an excel sheet. I assigned each card an integer 1 to 52 and set it up so that each suit is a sequential block of 13 cards. 1-13 = Clubs, 14-26 = Diamonds, 27-39 = Hearts, and 40-52 = Spades. I dealt each card into its own separate cell in adjacent columns. Ie B1:E1 is the hand and F1 is the turn. The hand (B1:E1) is also organised in the lowest card ID number (not card value) is on the left and the highest is on the right.

然后我开始研究如何使用 excel 公式对任何给定的牌进行评分.到目前为止,我已经能够检查 4 和 5 张同花顺(同花 = 所有牌相同花色)、对(包括 3 和 4 种)、15 种组合(2、3、4 和 5 张牌).我所擅长的是检查直道和旋钮的 1 分(手中的千斤顶匹配转牌).检查后者应该很容易.

Then I started tinkering with how to score any given hand using excel formulas. So far I have been able to check for a 4 and 5 card flush (flush=all cards same suit), Pairs (which includes three and four of a kind), 15 combinations (2,3,4 and 5 cards). What I have outstanding are checking for straights and 1 point for the knob (Jack in hand matches suit of turn). Checking the later should be easy enough.

Cribbage 中的顺子是最大的牌序列/系列.你不能昼夜不停,(即 3,2,1,13,12 或 3,2,A,K,Q).您不能计算 5 张牌顺子中的两个 4 张顺子,因为只计算最大的顺子.但是,您可以计算双顺子,例如 2,2,3,4,5 或 2,3,4,4,5.直线上的每张牌计为 1 分.

A straight in Cribbage is the largest sequence/series of cards. You cannot go around the clock, (ie 3,2,1,13,12 or 3,2,A,K,Q). You cannot count the two 4 card straights of a 5 card straight as only the largest is counted. However you can count double straight such as 2,2,3,4,5 or 2,3,4,4,5. Each card in a straight counts as 1 point.

当其中一张牌是双牌/对时,我不确定如何识别四张牌.艾.2、3、4、5、16 或 2、3、4、5、15 或 2、3、4、5、18.(面值:2,3,3,4,5 或 2,2,3,4,5 或 2,3,4,5,5)

I am not sure how to identify a four card straight when there is a double/pair of one of the cards. ei. 2,3,4,5,16 or 2,3,4,5,15 or 2,3,4,5,18. (Face value: 2,3,3,4,5 or 2,2,3,4,5 or 2,3,4,5,5)

我能够很容易地找出 5 张卡片,使用:MOD 将卡片转换为面值并剥离花色,A​​GGREGATE 对卡片进行排序,然后检查每张卡片是否与第一张卡片有适当的差异.该公式有点笨拙但有效:

I was able to figure out the 5 card straight easy enough using: MOD to convert the cards to face value and strip the suit, AGGREGATE to sort the cards, then checking if each card was the appropriate difference from the first card. The formula is a bit unwieldy but works:

=AND(
AGGREGATE(15,6,MOD(B1:F1,13),2)-AGGREGATE(15,6,MOD(B1:F1,13),1)=1,
AGGREGATE(15,6,MOD(B1:F1,13),3)-AGGREGATE(15,6,MOD(B1:F1,13),1)=2,
AGGREGATE(15,6,MOD(B1:F1,13),4)-AGGREGATE(15,6,MOD(B1:F1,13),1)=3,
AGGREGATE(15,6,MOD(B1:F1,13),5)-AGGREGATE(15,6,MOD(B1:F1,13),1)=4
)*5

然后我开始了 4 张牌的顺序.只要不是双直,我就能让它工作.

So then I started on the 4 card sequence. I am able to get it to work as long as it not a double straight.

=OR(AND(AGGREGATE(15,6,MOD(B1:F1,13),2)-AGGREGATE(15,6,MOD(B1:F1,13),1)=1,
AGGREGATE(15,6,MOD(B1:F1,13),3)-AGGREGATE(15,6,MOD(B1:F1,13),1)=2,
AGGREGATE(15,6,MOD(B1:F1,13),4)-AGGREGATE(15,6,MOD(B1:F1,13),1)=3,
AGGREGATE(15,6,MOD(B1:F1,13),5)-AGGREGATE(15,6,MOD(B1:F1,13),1)<>4),
AND(AGGREGATE(14,6,MOD(B1:F1,13),2)-AGGREGATE(14,6,MOD(B1:F1,13),1)=-1,
AGGREGATE(14,6,MOD(B1:F1,13),3)-AGGREGATE(14,6,MOD(B1:F1,13),1)=-2,
AGGREGATE(14,6,MOD(B1:F1,13),4)-AGGREGATE(14,6,MOD(B1:F1,13),1)=-3,
AGGREGATE(14,6,MOD(B1:F1,13),5)-AGGREGATE(14,6,MOD(B1:F1,13),1)<>-4))
*4

或者将其分解为单独的检查.

Or to break it out into its separate checks.

=AND(
AGGREGATE(15,6,MOD(B1:F1,13),2)-AGGREGATE(15,6,MOD(B1:F1,13),1)=1,
AGGREGATE(15,6,MOD(B1:F1,13),3)-AGGREGATE(15,6,MOD(B1:F1,13),1)=2,
AGGREGATE(15,6,MOD(B1:F1,13),4)-AGGREGATE(15,6,MOD(B1:F1,13),1)=3,
AGGREGATE(15,6,MOD(B1:F1,13),5)-AGGREGATE(15,6,MOD(B1:F1,13),1)<>4
)*4

AND(
AGGREGATE(14,6,MOD(B1:F1,13),2)-AGGREGATE(14,6,MOD(B1:F1,13),1)=-1,
AGGREGATE(14,6,MOD(B1:F1,13),3)-AGGREGATE(14,6,MOD(B1:F1,13),1)=-2,
AGGREGATE(14,6,MOD(B1:F1,13),4)-AGGREGATE(14,6,MOD(B1:F1,13),1)=-3,
AGGREGATE(14,6,MOD(B1:F1,13),5)-AGGREGATE(14,6,MOD(B1:F1,13),1)<>-4
)*4

问题

最终如何使用excel公式最好在单个单元格中找到带有双/对的四张牌.我不介意使用多个单元格来构建和理解公式.

Question

How to find a four card straight with a double/pair using excel formulas preferably in a single cell eventually. I do not mind multiple cells for building and understanding the formula.

是否有更好的方法使用 excel 公式识别直线?

Is there a better way to identify a straight using excel formulas?

我希望建立在 4 张顺子的概念上,当我想通之后,处理 3 张顺子.

I am hoping to build on the concept for 4 card straight, when figured out, to look after 3 card straights.

| B | C | D | E | F  |
+---+---+---+---+----+
| 2 | 3 | 4 | 5 | 14 |   <= 5 card straight
| 2 | 3 | 4 | 5 | 16 |   <= 2 X 4 card straight
| 2 | 3 | 4 | 5 | 15 |   <= 2 X 4 card straight
| 2 | 3 | 4 | 5 | 18 |   <= 2 X 4 card straight
| 2 | 3 | 4 | 20| 5  |   <= 1 X 4 card straight
| 2 | 3 | 4 | 8 | 10 |   <= Not a straight

Excel 版本

我正在运行 excel 2013

Excel Version

I am running excel 2013

推荐答案

我们可以将 SUMPRODUCT 与 AGGREGATE 一起使用:

We can use SUMPRODUCT with AGGREGATE:

=IF(SUMPRODUCT(--(AGGREGATE(14,7,MOD(B1:F1-1,13)+1,{1,2,3,4})-AGGREGATE(14,7,MOD(B1:F1-1,13)+1,{2,3,4,5})=1))=4,"5 card straight",
 IF(AND(SUMPRODUCT(--(AGGREGATE(14,7,MOD(B1:F1-1,13)+1,{1,2,3,4})-AGGREGATE(14,7,MOD(B1:F1-1,13)+1,{2,3,4,5})=1))=3,AGGREGATE(14,7,MOD(B1:F1-1,13)+1,1)-AGGREGATE(15,7,MOD(B1:F1-1,13)+1,1)=3),"2 X 4 card straight",
IF(AND(SUMPRODUCT(--(AGGREGATE(14,7,MOD(B1:F1-1,13)+1,{1,2,3,4})-AGGREGATE(14,7,MOD(B1:F1-1,13)+1,{2,3,4,5})=1))=3,OR(AGGREGATE(14,7,MOD(B1:F1-1,13)+1,2)-AGGREGATE(15,7,MOD(B1:F1-1,13)+1,1)=3,AGGREGATE(14,7,MOD(B1:F1-1,13)+1,1)-AGGREGATE(15,7,MOD(B1:F1-1,13)+1,2)=3)),"1 X 4 card straight","Not a Straight")))

这篇关于在 cribbage 中找到一条直线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆