1.针对有胡牌后有多种牌型可搭配,筛选出其中番数最大的一种。
2.步骤:
a.筛选出所有AAA,ABC,AA的搭配。
b.组合所有可能性的搭配,并计算番数
3.部分代码
public static List> filterAllKeziAndShunziCombo(int[] cards, int jokerNum, int jokerPos) {
List> tmpCompany = new ArrayList>();
// 有三个财神,先组合成一个刻字
if (jokerNum >= 3) {
ArrayList tmp = new ArrayList();
tmp.add(-1);
tmp.add(-1);
tmp.add(-1);
tmpCompany.add(tmp);
}
for (int i = 0; i < 34; i++) {
if (cards[i] >= 3 || cards[i] + jokerNum >= 3) {
ArrayList tmp1 = new ArrayList();
tmp1.add(cards[i] >= 1 ? i : -1);
tmp1.add(cards[i] >= 2 ? i : -1);
tmp1.add(cards[i] >= 3 ? i : -1);
tmpCompany.add(tmp1);
if (cards[i] >= 3 && jokerNum >= 1) {
// 三张里抽两张配一个财神
ArrayList tmp2 = new ArrayList();
tmp2.add(i);
tmp2.add(i);
tmp2.add(-1);
tmpCompany.add(tmp2);
// 三张里抽一张配一个财神
if (jokerNum >= 2) {
ArrayList tmp3 = new ArrayList();
tmp3.add(i);
tmp3.add(-1);
tmp3.add(-1);
tmpCompany.add(tmp3);
}
}
}
if (i < 27 && MjCommonUtils.GetCardValueByIndex(i) <= 7) {
int shunziNum = cards[i] + cards[i + 1] + cards[i + 2];
if (shunziNum == 0 || shunziNum + jokerNum < 3) {
continue;
}
int[] sunziPerNum = {cards[i], cards[i + 1], cards[i + 2]};
int tmpJokerNum = jokerNum;
while (sunziPerNum[0] + sunziPerNum[1] + sunziPerNum[2] + tmpJokerNum >= 3) {
ArrayList tmp = new ArrayList();
for (int j = 0; j < 3; j++) {
if (sunziPerNum[j] > 0) {
sunziPerNum[j]--;
tmp.add(i + j);
} else {
tmpJokerNum--;
tmp.add(-1);
}
}
// 要避免出现刻字的情况,如果财神用来两张或以上,肯定就不是顺子了
if (jokerNum >= 1 && tmpJokerNum >= 0 && jokerNum == tmpJokerNum) {
// 不带财神顺子
tmpCompany.add(tmp);
// 单张财神顺子
for (int m = 0; m < 3; m++) {
ArrayList tmp1 = new ArrayList();
tmp1.addAll(tmp);
tmp1.set(m, -1);
tmpCompany.add(tmp1);
}
} else if (tmpJokerNum >= 0 && jokerNum - tmpJokerNum <= 1) {
tmpCompany.add(tmp);
} else {
break;
}
}
}
}
// 财神和替代牌还原
for (int m = 0; m < tmpCompany.size(); m++) {
for (int n = 0; n < tmpCompany.get(m).size(); n++) {
if (tmpCompany.get(m).get(n) == -1) {
tmpCompany.get(m).set(n, jokerPos);
} else if (tmpCompany.get(m).get(n) == jokerPos) {
tmpCompany.get(m).set(n, 33);
}
}
}
return tmpCompany;
}
4.写的比较随意,希望思路能给你帮助。



