github.com/jefffederman/gophe@v0.0.0-20221203163656-b38beff92772/examples/potodds/main.go (about)

     1  package main
     2  
     3  import (
     4  	"fmt"
     5  
     6  	"github.com/jefffederman/gophe"
     7  )
     8  
     9  func main() {
    10  	fmt.Printf("Input card 1: ")
    11  
    12  	c1 := gophe.NewCard("Qc")
    13  	fmt.Printf("Input card 2: ")
    14  	c2 := gophe.NewCard("Qd")
    15  
    16  	dealt := 0
    17  	for i := 0; i < dealt; i++ {
    18  		fmt.Printf("Communitty card %d:", i)
    19  	}
    20  	var a uint8
    21  	var o1 uint8
    22  	var wins int = 0
    23  	var losses int = 0
    24  	var ties int = 0
    25  	var total int = 0
    26  	for a = 0; a < 48; a++ {
    27  		if a == c1.ID() || a == c2.ID() {
    28  			continue
    29  		}
    30  		for b := a + 1; b < 49; b++ {
    31  			if b == c1.ID() || b == c2.ID() {
    32  				continue
    33  			}
    34  			for c := b + 1; c < 50; c++ {
    35  				if c == c1.ID() || c == c2.ID() {
    36  					continue
    37  				}
    38  				for d := c + 1; d < 51; d++ {
    39  					if d == c1.ID() || d == c2.ID() {
    40  						continue
    41  					}
    42  					for e := d + 1; e < 52; e++ {
    43  						if e == c1.ID() || e == c2.ID() {
    44  							continue
    45  						}
    46  						cc := gophe.NewHand(
    47  							gophe.NewCardFromId(a),
    48  							gophe.NewCardFromId(b),
    49  							gophe.NewCardFromId(c),
    50  							gophe.NewCardFromId(d),
    51  							gophe.NewCardFromId(e),
    52  						)
    53  						for o1 = 0; o1 < 51; o1++ {
    54  							if o1 == a || o1 == b || o1 == c || o1 == d || o1 == e || o1 == c1.ID() || o1 == c2.ID() {
    55  								continue
    56  							}
    57  							for o2 := o1 + 1; o2 < 52; o2++ {
    58  								if o2 == a || o2 == b || o2 == c || o2 == d || o2 == e || o2 == c1.ID() || o2 == c2.ID() {
    59  									continue
    60  								}
    61  								h1 := cc.AddCards(c1, c2)
    62  								h2 := cc.AddCards(gophe.NewCardFromId(o1), gophe.NewCardFromId(o2))
    63  								r1 := gophe.EvaluateHand(h1)
    64  								r2 := gophe.EvaluateHand(h2)
    65  								total++
    66  								if r1.Compare(r2) > 0 {
    67  									wins++
    68  								} else if r2.Compare(r1) > 0 {
    69  									losses++
    70  								} else {
    71  									ties++
    72  								}
    73  							}
    74  						}
    75  					}
    76  				}
    77  			}
    78  		}
    79  	}
    80  	fmt.Printf("Wins: %d\n", wins)
    81  	fmt.Printf("Losses: %d\n", losses)
    82  	fmt.Printf("Ties: %d\n", ties)
    83  	fmt.Printf("Total: %d\n", total)
    84  }