latest, found a bug, wrote a failing test

This commit is contained in:
2024-05-18 17:33:15 -07:00
parent 90a959448a
commit eb85e1d36e
22 changed files with 661 additions and 460 deletions

View File

@@ -0,0 +1,34 @@
package main
import (
"fmt"
"git.eeqj.de/sneak/pokercore"
)
func main() {
for i := 0; i < 10; i++ {
d := pokercore.NewDeck()
fmt.Printf("deck before shuffling: %s\n", d.FormatForTerminal())
d.ShuffleRandomly()
fmt.Printf("deck after shuffling: %s\n", d.FormatForTerminal())
offTheTop := d.Deal(11)
fmt.Printf("off the top: %s\n", offTheTop.FormatForTerminal())
wh, err := offTheTop.IdentifyBestFiveCardPokerHand()
if err != nil {
panic(err)
}
fmt.Printf("best hand: %s\n", wh.FormatForTerminalSorted(pokercore.AceHighAscending))
score, err := wh.PokerHandScore()
if err != nil {
panic(err)
}
fmt.Printf("best hand score: %s\n", score)
ph, err := wh.PokerHand()
if err != nil {
panic(err)
}
fmt.Printf("best hand string: %s\n", ph.Description())
}
}

BIN
examples/searchbig/searchbig Executable file

Binary file not shown.

35
examples/sixhand/main.go Normal file
View File

@@ -0,0 +1,35 @@
package main
import (
"fmt"
"git.eeqj.de/sneak/pokercore"
)
func main() {
d := pokercore.NewDeck()
fmt.Printf("deck before shuffling: %s\n", d.FormatForTerminal())
d.ShuffleDeterministically(1337 + 1) // 1337 gives too weird a result
fmt.Printf("deck after shuffling: %s\n", d.FormatForTerminal())
var players []pokercore.Cards
for i := 0; i < 6; i++ {
players = append(players, d.Deal(2))
}
for i, p := range players {
fmt.Printf("player %d: %s\n", i, p.FormatForTerminal())
}
// deal the flop
var community pokercore.Cards
community = d.Deal(3)
fmt.Printf("flop: %s\n", community.FormatForTerminal())
// evaluate the hands so far
for i, p := range players {
fmt.Printf("player %d: %s\n", i, p.FormatForTerminal())
thisPlayersHand, err := p.Append(community).PokerHand()
if err != nil {
fmt.Printf("error evaluating hand: %s\n", err)
continue
}
fmt.Printf("player %d: %s\n", i, thisPlayersHand.String())
}
}

BIN
examples/sixhand/sixhand Executable file

Binary file not shown.