Compare commits
No commits in common. "7198f8c99f19efeafca960e163a83e784ad477ac" and "3e853c2434c93fae83be29b4d8e68cd461bb9f5e" have entirely different histories.
7198f8c99f
...
3e853c2434
|
@ -245,35 +245,36 @@ func (l *Logic) SortMidAndEnd(cards *Group) *Group {
|
|||
// 不可能
|
||||
} else if n == 0 { // 逻辑点数相同
|
||||
// 比花色,比三条就行了
|
||||
n, index1, index2 := IndexCompareColorByLogic(c1, c2)
|
||||
//n, index1, index2 := IndexCompareColorByLogic(c1, c2)
|
||||
n = 0
|
||||
if n == 1 {
|
||||
// 花色交换,结束
|
||||
if index1 >= 0 && index2 >= 0 {
|
||||
for k, v := range cards.Head {
|
||||
if v == r1[index1] {
|
||||
cards.Head[k] = -1
|
||||
break
|
||||
}
|
||||
}
|
||||
for k, v := range cards.Mid {
|
||||
if v == r2[index2] {
|
||||
cards.Mid[k] = -1
|
||||
break
|
||||
}
|
||||
}
|
||||
for k, v := range cards.Head {
|
||||
if v == -1 && r2[index2] >= 0 {
|
||||
cards.Head[k] = r2[index2]
|
||||
break
|
||||
}
|
||||
}
|
||||
for k, v := range cards.Mid {
|
||||
if v == -1 && r1[index1] >= 0 {
|
||||
cards.Mid[k] = r1[index1]
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
//if index1 >= 0 && index2 >= 0 {
|
||||
// for k, v := range cards.Head {
|
||||
// if v == r1[index1] {
|
||||
// cards.Head[k] = -1
|
||||
// break
|
||||
// }
|
||||
// }
|
||||
// for k, v := range cards.Mid {
|
||||
// if v == r2[index2] {
|
||||
// cards.Mid[k] = -1
|
||||
// break
|
||||
// }
|
||||
// }
|
||||
// for k, v := range cards.Head {
|
||||
// if v == -1 && r2[index2] >= 0 {
|
||||
// cards.Head[k] = r2[index2]
|
||||
// break
|
||||
// }
|
||||
// }
|
||||
// for k, v := range cards.Mid {
|
||||
// if v == -1 && r1[index1] >= 0 {
|
||||
// cards.Mid[k] = r1[index1]
|
||||
// break
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
} else if n == 0 {
|
||||
// 比癞子数
|
||||
if l.LaiZiCount(r1) < l.LaiZiCount(r2) {
|
||||
|
@ -380,12 +381,13 @@ func (l *Logic) SortMidAndEnd(cards *Group) *Group {
|
|||
}
|
||||
} else if n == 0 { // 点数相同
|
||||
// 比花色
|
||||
n, index1, index2 := IndexCompareColorByLogic(nHead[:], nMid[:])
|
||||
//n, index1, index2 := IndexCompareColorByLogic(nHead[:], nMid[:])
|
||||
n = 0
|
||||
if n == 1 {
|
||||
// 交换花色,结束
|
||||
if index1 >= 0 && index2 >= 0 {
|
||||
cards.Head[index1], cards.Mid[index2] = cards.Mid[index2], cards.Head[index1]
|
||||
}
|
||||
//if index1 >= 0 && index2 >= 0 {
|
||||
// cards.Head[index1], cards.Mid[index2] = cards.Mid[index2], cards.Head[index1]
|
||||
//}
|
||||
} else if n == 0 {
|
||||
// 比癞子多少
|
||||
if l.LaiZiCount(r1) < l.LaiZiCount(r2) {
|
||||
|
@ -424,13 +426,13 @@ func (l *Logic) SortMidAndEnd(cards *Group) *Group {
|
|||
}
|
||||
} else if n == 0 {
|
||||
// 点数相同比花色
|
||||
n, index1, index2 := IndexCompareColorByLogic(cards.Head[:], cards.Mid[:])
|
||||
if n == 1 {
|
||||
// 交换最大花色的牌
|
||||
if index1 >= 0 && index2 >= 0 {
|
||||
cards.Head[index1], cards.Mid[index2] = cards.Mid[index2], cards.Head[index1]
|
||||
}
|
||||
}
|
||||
//n, index1, index2 := IndexCompareColorByLogic(cards.Head[:], cards.Mid[:])
|
||||
//if n == 1 {
|
||||
// // 交换最大花色的牌
|
||||
// if index1 >= 0 && index2 >= 0 {
|
||||
// cards.Head[index1], cards.Mid[index2] = cards.Mid[index2], cards.Head[index1]
|
||||
// }
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -832,10 +834,10 @@ func (l *Logic) CompareHead(c, cs [3]int) int {
|
|||
return n
|
||||
}
|
||||
// 比花色
|
||||
n = CompareColorByLogic(c1, c2)
|
||||
if n != 0 {
|
||||
return n
|
||||
}
|
||||
//n = CompareColorByLogic(c1, c2)
|
||||
//if n != 0 {
|
||||
// return n
|
||||
//}
|
||||
// 比癞子数
|
||||
z1, z2 := l.LaiZiCount(c[:]), l.LaiZiCount(cs[:])
|
||||
if z1 < z2 {
|
||||
|
@ -867,10 +869,10 @@ func (l *Logic) CompareFive(c, cs [5]int) int {
|
|||
return n
|
||||
}
|
||||
// 比花色
|
||||
n = CompareColorByLogic(c1, c2)
|
||||
if n != 0 {
|
||||
return n
|
||||
}
|
||||
//n = CompareColorByLogic(c1, c2)
|
||||
//if n != 0 {
|
||||
// return n
|
||||
//}
|
||||
|
||||
case PokersTypeStraightFlush:
|
||||
_, c1 := FindMaxSameColorFlush(c[:], l.LaiZi)
|
||||
|
@ -886,20 +888,20 @@ func (l *Logic) CompareFive(c, cs [5]int) int {
|
|||
}
|
||||
if ch1 && ch2 {
|
||||
// 比花色
|
||||
n := CompareColorByLogic(c1, c2)
|
||||
if n != 0 {
|
||||
return n
|
||||
}
|
||||
//n := CompareColorByLogic(c1, c2)
|
||||
//if n != 0 {
|
||||
// return n
|
||||
//}
|
||||
} else if !ch1 && !ch2 {
|
||||
n := CompareLogic(c1, c2)
|
||||
if n != 0 {
|
||||
return n
|
||||
}
|
||||
// 比花色
|
||||
n = CompareColorByLogic(c1, c2)
|
||||
if n != 0 {
|
||||
return n
|
||||
}
|
||||
//n = CompareColorByLogic(c1, c2)
|
||||
//if n != 0 {
|
||||
// return n
|
||||
//}
|
||||
} else {
|
||||
if ch1 {
|
||||
return -1
|
||||
|
@ -926,10 +928,10 @@ func (l *Logic) CompareFive(c, cs [5]int) int {
|
|||
return n
|
||||
}
|
||||
// 比花色
|
||||
n = CompareColorByLogic(c1, c2)
|
||||
if n != 0 {
|
||||
return n
|
||||
}
|
||||
//n = CompareColorByLogic(c1, c2)
|
||||
//if n != 0 {
|
||||
// return n
|
||||
//}
|
||||
|
||||
case PokersTypeFullHouse:
|
||||
_, c1 := FindMaxGourdCards(c[:], l.LaiZi)
|
||||
|
@ -944,10 +946,10 @@ func (l *Logic) CompareFive(c, cs [5]int) int {
|
|||
return n
|
||||
}
|
||||
// 比花色
|
||||
n = CompareColorByLogic(c1, c2)
|
||||
if n != 0 {
|
||||
return n
|
||||
}
|
||||
//n = CompareColorByLogic(c1, c2)
|
||||
//if n != 0 {
|
||||
// return n
|
||||
//}
|
||||
|
||||
case PokersTypeFlush:
|
||||
_, c1 := FindMaxSameColors(c[:], l.LaiZi)
|
||||
|
@ -958,10 +960,10 @@ func (l *Logic) CompareFive(c, cs [5]int) int {
|
|||
return n
|
||||
}
|
||||
// 比花色
|
||||
n = CompareColorByLogic(c1, c2)
|
||||
if n != 0 {
|
||||
return n
|
||||
}
|
||||
//n = CompareColorByLogic(c1, c2)
|
||||
//if n != 0 {
|
||||
// return n
|
||||
//}
|
||||
|
||||
case PokersTypeStraight:
|
||||
_, c1 := FindMaxFlush(c[:], l.LaiZi)
|
||||
|
@ -977,20 +979,20 @@ func (l *Logic) CompareFive(c, cs [5]int) int {
|
|||
}
|
||||
if ch1 && ch2 {
|
||||
// 比花色
|
||||
n := CompareColorByLogic(c1, c2)
|
||||
if n != 0 {
|
||||
return n
|
||||
}
|
||||
//n := CompareColorByLogic(c1, c2)
|
||||
//if n != 0 {
|
||||
// return n
|
||||
//}
|
||||
} else if !ch1 && !ch2 {
|
||||
n := CompareLogic(c1, c2)
|
||||
if n != 0 {
|
||||
return n
|
||||
}
|
||||
// 比花色
|
||||
n = CompareColorByLogic(c1, c2)
|
||||
if n != 0 {
|
||||
return n
|
||||
}
|
||||
//n = CompareColorByLogic(c1, c2)
|
||||
//if n != 0 {
|
||||
// return n
|
||||
//}
|
||||
} else {
|
||||
if ch1 {
|
||||
return -1
|
||||
|
@ -1017,10 +1019,10 @@ func (l *Logic) CompareFive(c, cs [5]int) int {
|
|||
return n
|
||||
}
|
||||
// 比花色
|
||||
n = CompareColorByLogic(c1, c2)
|
||||
if n != 0 {
|
||||
return n
|
||||
}
|
||||
//n = CompareColorByLogic(c1, c2)
|
||||
//if n != 0 {
|
||||
// return n
|
||||
//}
|
||||
|
||||
case PokersTypeTwoPairs:
|
||||
r1, c1 := FindMaxPairs(c[:], l.LaiZi)
|
||||
|
@ -1051,10 +1053,10 @@ func (l *Logic) CompareFive(c, cs [5]int) int {
|
|||
return n
|
||||
}
|
||||
// 比花色
|
||||
n = CompareColorByLogic(c1, c2)
|
||||
if n != 0 {
|
||||
return n
|
||||
}
|
||||
//n = CompareColorByLogic(c1, c2)
|
||||
//if n != 0 {
|
||||
// return n
|
||||
//}
|
||||
|
||||
case PokersTypePair:
|
||||
r1, c1 := FindMaxPairs(c[:], l.LaiZi)
|
||||
|
@ -1075,10 +1077,10 @@ func (l *Logic) CompareFive(c, cs [5]int) int {
|
|||
return n
|
||||
}
|
||||
// 比花色
|
||||
n = CompareColorByLogic(c1, c2)
|
||||
if n != 0 {
|
||||
return n
|
||||
}
|
||||
//n = CompareColorByLogic(c1, c2)
|
||||
//if n != 0 {
|
||||
// return n
|
||||
//}
|
||||
|
||||
case PokersTypeOne:
|
||||
// 乌龙不会有癞子
|
||||
|
@ -1088,10 +1090,10 @@ func (l *Logic) CompareFive(c, cs [5]int) int {
|
|||
return n
|
||||
}
|
||||
// 比花色
|
||||
n = CompareColorByLogic(c[:], cs[:])
|
||||
if n != 0 {
|
||||
return n
|
||||
}
|
||||
//n = CompareColorByLogic(c[:], cs[:])
|
||||
//if n != 0 {
|
||||
// return n
|
||||
//}
|
||||
return 0
|
||||
}
|
||||
|
||||
|
@ -1134,10 +1136,10 @@ func (l *Logic) IsDP(head [3]int, mid, end [5]int) bool {
|
|||
return n == 1
|
||||
}
|
||||
// 比花色
|
||||
n = CompareColorByLogic(c1, changeMid)
|
||||
if n != 0 {
|
||||
return n == 1
|
||||
}
|
||||
//n = CompareColorByLogic(c1, changeMid)
|
||||
//if n != 0 {
|
||||
// return n == 1
|
||||
//}
|
||||
// 比癞子数
|
||||
z1, z2 := l.LaiZiCount(r1), l.LaiZiCount(r2)
|
||||
if z1 < z2 {
|
||||
|
@ -1162,10 +1164,10 @@ func (l *Logic) IsDP(head [3]int, mid, end [5]int) bool {
|
|||
return n == 1
|
||||
}
|
||||
// 比花色
|
||||
n = CompareColorByLogic(c1, changeMid)
|
||||
if n != 0 {
|
||||
return n == 1
|
||||
}
|
||||
//n = CompareColorByLogic(c1, changeMid)
|
||||
//if n != 0 {
|
||||
// return n == 1
|
||||
//}
|
||||
// 比癞子数
|
||||
z1, z2 := l.LaiZiCount(r1), l.LaiZiCount(r2)
|
||||
if z1 < z2 {
|
||||
|
@ -1182,10 +1184,10 @@ func (l *Logic) IsDP(head [3]int, mid, end [5]int) bool {
|
|||
return n == 1
|
||||
}
|
||||
// 比花色
|
||||
n = CompareColorByLogic(head[:], mid[:])
|
||||
if n != 0 {
|
||||
return n == 1
|
||||
}
|
||||
//n = CompareColorByLogic(head[:], mid[:])
|
||||
//if n != 0 {
|
||||
// return n == 1
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -165,29 +165,6 @@ func TestLogic_CompareHead(t *testing.T) {
|
|||
l.LaiZi = []int{52, 53}
|
||||
data := [][]int{
|
||||
// 比花色的
|
||||
{1, 27, 49, 50, 43, 42, 1},
|
||||
{47, 20, 23, 29, 36, 42, -1},
|
||||
{0, 2, 18, 31, 21, 29, -1},
|
||||
{45, 7, 18, 13, 15, 29, 1},
|
||||
{14, 4, 46, 9, 1, 11, -1},
|
||||
{7, 3, 24, 43, 50, 44, 1},
|
||||
{5, 4, 31, 15, 33, 14, 1},
|
||||
{21, 21, 32, 31, 38, 28, 1},
|
||||
{47, 38, 49, 30, 34, 23, 1},
|
||||
{14, 10, 16, 29, 30, 35, 1},
|
||||
//
|
||||
{0, 52, 8, 7, 8, 9, 1},
|
||||
{0, 52, 52, 7, 8, 9, 1},
|
||||
{0, 52, 52, 7, 51, 53, 1},
|
||||
{0, 52, 51, 7, 51, 53, -1},
|
||||
{8, 52, 51, 7, 51, 53, 1},
|
||||
{7, 52, 51, 7, 51, 53, 0},
|
||||
{7, 9, 22, 22, 7, 53, -1},
|
||||
{7, 48, 22, 22, 7, 53, 1},
|
||||
{7, 48, 22, 22, 6, 53, 1},
|
||||
{7, 48, 22, 22, 20, 53, -1},
|
||||
|
||||
// 不比花色
|
||||
//{1, 27, 49, 50, 43, 42, 1},
|
||||
//{47, 20, 23, 29, 36, 42, -1},
|
||||
//{0, 2, 18, 31, 21, 29, -1},
|
||||
|
@ -205,10 +182,33 @@ func TestLogic_CompareHead(t *testing.T) {
|
|||
//{0, 52, 51, 7, 51, 53, -1},
|
||||
//{8, 52, 51, 7, 51, 53, 1},
|
||||
//{7, 52, 51, 7, 51, 53, 0},
|
||||
//{7, 9, 22, 22, 7, 53, 1},
|
||||
//{7, 9, 22, 22, 7, 53, -1},
|
||||
//{7, 48, 22, 22, 7, 53, 1},
|
||||
//{7, 48, 22, 22, 6, 53, 1},
|
||||
//{7, 48, 22, 22, 20, 53, 1},
|
||||
//{7, 48, 22, 22, 20, 53, -1},
|
||||
|
||||
// 不比花色
|
||||
{1, 27, 49, 50, 43, 42, 1},
|
||||
{47, 20, 23, 29, 36, 42, -1},
|
||||
{0, 2, 18, 31, 21, 29, -1},
|
||||
{45, 7, 18, 13, 15, 29, 1},
|
||||
{14, 4, 46, 9, 1, 11, -1},
|
||||
{7, 3, 24, 43, 50, 44, 1},
|
||||
{5, 4, 31, 15, 33, 14, 1},
|
||||
{21, 21, 32, 31, 38, 28, 1},
|
||||
{47, 38, 49, 30, 34, 23, 1},
|
||||
{14, 10, 16, 29, 30, 35, 1},
|
||||
//
|
||||
{0, 52, 8, 7, 8, 9, 1},
|
||||
{0, 52, 52, 7, 8, 9, 1},
|
||||
{0, 52, 52, 7, 51, 53, 1},
|
||||
{0, 52, 51, 7, 51, 53, -1},
|
||||
{8, 52, 51, 7, 51, 53, 1},
|
||||
{7, 52, 51, 7, 51, 53, 0},
|
||||
{7, 9, 22, 22, 7, 53, 1},
|
||||
{7, 48, 22, 22, 7, 53, 1},
|
||||
{7, 48, 22, 22, 6, 53, 1},
|
||||
{7, 48, 22, 22, 20, 53, 1},
|
||||
}
|
||||
|
||||
for _, v := range data {
|
||||
|
@ -233,33 +233,6 @@ func TestLogic_CompareFive(t *testing.T) {
|
|||
l := new(Logic)
|
||||
l.LaiZi = []int{52, 53}
|
||||
data := [][]int{
|
||||
// 不比花色
|
||||
//{5, 23, 10, 6, 1, 45, 41, 20, 1, 13, 1},
|
||||
//{29, 31, 26, 1, 39, 31, 44, 17, 9, 34, -1},
|
||||
//{24, 26, 9, 10, 0, 16, 30, 7, 37, 3, -1},
|
||||
//{31, 30, 11, 33, 7, 18, 1, 36, 9, 3, 1},
|
||||
//// 牌型不同
|
||||
//{2, 15, 28, 0, 6, 12, 0, 1, 2, 3, -1},
|
||||
//// 点数不同
|
||||
//{2, 15, 28, 0, 6, 2, 15, 28, 0, 6, 0},
|
||||
//{2, 15, 28, 0, 6, 2, 15, 28, 0, 7, -1},
|
||||
//{0, 13, 4, 17, 6, 0, 13, 4, 17, 5, 1},
|
||||
//{0, 13, 5, 18, 6, 0, 13, 4, 17, 6, 1},
|
||||
//{1, 14, 4, 17, 6, 0, 13, 4, 17, 5, 1},
|
||||
//// 花色不同
|
||||
//{2, 15, 28, 0, 6, 2, 15, 28, 0, 19, 0},
|
||||
//{41, 15, 28, 0, 6, 2, 15, 28, 0, 6, 0},
|
||||
//{2, 15, 28, 0, 6, 2, 15, 28, 13, 6, 0},
|
||||
//{3, 4, 5, 6, 52, 3, 52, 5, 6, 53, 1},
|
||||
//{3, 17, 5, 6, 52, 3, 52, 5, 6, 53, -1},
|
||||
//{3, 4, 5, 6, 7, 16, 52, 18, 19, 53, 1},
|
||||
//{3, 52, 5, 6, 20, 3, 17, 18, 19, 53, 0},
|
||||
//{3, 52, 5, 6, 46, 3, 17, 18, 19, 53, 0},
|
||||
//// 癞子数不同
|
||||
//{52, 52, 7, 20, 12, 52, 7, 20, 33, 25, -1},
|
||||
//{52, 33, 7, 20, 12, 52, 7, 20, 33, 25, 0},
|
||||
|
||||
// 比花色
|
||||
{5, 23, 10, 6, 1, 45, 41, 20, 1, 13, 1},
|
||||
{29, 31, 26, 1, 39, 31, 44, 17, 9, 34, -1},
|
||||
{24, 26, 9, 10, 0, 16, 30, 7, 37, 3, -1},
|
||||
|
@ -273,17 +246,17 @@ func TestLogic_CompareFive(t *testing.T) {
|
|||
{0, 13, 5, 18, 6, 0, 13, 4, 17, 6, 1},
|
||||
{1, 14, 4, 17, 6, 0, 13, 4, 17, 5, 1},
|
||||
// 花色不同
|
||||
{2, 15, 28, 0, 6, 2, 15, 28, 0, 19, -1},
|
||||
{41, 15, 28, 0, 6, 2, 15, 28, 0, 6, 1},
|
||||
{2, 15, 28, 0, 6, 2, 15, 28, 13, 6, -1},
|
||||
{2, 15, 28, 0, 6, 2, 15, 28, 0, 19, 0},
|
||||
{41, 15, 28, 0, 6, 2, 15, 28, 0, 6, 0},
|
||||
{2, 15, 28, 0, 6, 2, 15, 28, 13, 6, 0},
|
||||
{3, 4, 5, 6, 52, 3, 52, 5, 6, 53, 1},
|
||||
{3, 17, 5, 6, 52, 3, 52, 5, 6, 53, -1},
|
||||
{3, 4, 5, 6, 7, 16, 52, 18, 19, 53, -1},
|
||||
{3, 52, 5, 6, 20, 3, 17, 18, 19, 53, -1},
|
||||
{3, 52, 5, 6, 46, 3, 17, 18, 19, 53, -1},
|
||||
{3, 4, 5, 6, 7, 16, 52, 18, 19, 53, 1},
|
||||
{3, 52, 5, 6, 20, 3, 17, 18, 19, 53, 0},
|
||||
{3, 52, 5, 6, 46, 3, 17, 18, 19, 53, 0},
|
||||
// 癞子数不同
|
||||
{52, 52, 7, 20, 12, 52, 7, 20, 33, 25, -1},
|
||||
{52, 33, 7, 20, 12, 52, 7, 20, 33, 25, -1},
|
||||
{52, 33, 7, 20, 12, 52, 7, 20, 33, 25, 0},
|
||||
}
|
||||
|
||||
for _, v := range data {
|
||||
|
|
Loading…
Reference in New Issue