示例#1
0
文件: util_test.go 项目: notnil/joker
func TestCombinations(t *testing.T) {
	for _, c := range combos {
		result := util.Combinations(c.n, c.k)
		if !reflect.DeepEqual(result, c.combo) {
			t.Fatalf("util.Combinations(%d, %d) => %v, want %v", c.n, c.k, result, c.combo)
		}
	}
}
示例#2
0
文件: game.go 项目: notnil/joker
func omahaHands(holeCards []*hand.Card, board []*hand.Card, opts func(*hand.Config)) []*hand.Hand {
	hands := []*hand.Hand{}
	selected := make([]*hand.Card, 2)
	for _, indexes := range util.Combinations(4, 2) {
		for j, i := range indexes {
			selected[j] = holeCards[i]
		}
		cards := append(board, selected...)
		hands = append(hands, hand.New(cards, opts))
	}
	return hands
}
示例#3
0
文件: hand.go 项目: notnil/joker
func cardCombos(cards []*Card) [][]*Card {
	cCombo := [][]*Card{}
	l := 5
	if len(cards) < 5 {
		l = len(cards)
	}
	indexCombos := util.Combinations(len(cards), l)

	for _, combo := range indexCombos {
		cCards := []*Card{}
		for _, i := range combo {
			cCards = append(cCards, cards[i])
		}
		cCombo = append(cCombo, cCards)
	}
	return cCombo
}