Esempio n. 1
0
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)
		}
	}
}
Esempio n. 2
0
File: game.go Progetto: 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
}
Esempio n. 3
0
File: hand.go Progetto: 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
}