예제 #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
}