latest
This commit is contained in:
56
examples/sf/main.go
Normal file
56
examples/sf/main.go
Normal file
@@ -0,0 +1,56 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"sneak.berlin/go/pokercore"
|
||||
)
|
||||
|
||||
func main() {
|
||||
var sfp bool
|
||||
var tries int
|
||||
var found int
|
||||
|
||||
const maxTries = 100_000_000
|
||||
|
||||
for i := 0; i < maxTries; i++ {
|
||||
sfp = searchStraightFlush()
|
||||
if sfp {
|
||||
found++
|
||||
}
|
||||
tries++
|
||||
if tries%1000 == 0 {
|
||||
fmt.Printf("Tries: %d, Found: %d\n", tries, found)
|
||||
}
|
||||
}
|
||||
fmt.Printf("Tries: %d, Found: %d\n", tries, found)
|
||||
}
|
||||
|
||||
func searchStraightFlush() bool {
|
||||
|
||||
d := pokercore.NewDeck()
|
||||
|
||||
d.ShuffleRandomly()
|
||||
|
||||
var hand pokercore.Cards
|
||||
|
||||
hand = d.Deal(7)
|
||||
|
||||
ph, err := hand.PokerHand()
|
||||
|
||||
if err != nil {
|
||||
fmt.Println("Error: ", err)
|
||||
return false
|
||||
}
|
||||
|
||||
if ph.Type == pokercore.StraightFlush ||
|
||||
ph.Type == pokercore.RoyalFlush {
|
||||
fmt.Println("straight flush found")
|
||||
fmt.Println("Hand: ", hand.FormatForTerminal())
|
||||
fmt.Println("PokerHand: ", ph)
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user