package main import ( "fmt" "time" "git.eeqj.de/sneak/pokercore" ) func main() { sleepTime := 2 * time.Second playerCount := 8 d := pokercore.NewDeck() fmt.Printf("deck before shuffling: %s\n", d.FormatForTerminal()) // this "randomly chosen" seed somehow deals pocket queens, pocket kings, and pocket aces to three players. // what are the odds? lol d.ShuffleDeterministically(1337) fmt.Printf("deck after shuffling: %s\n", d.FormatForTerminal()) var players []pokercore.Cards for i := 0; i < playerCount; i++ { players = append(players, d.Deal(2)) } for i, p := range players { fmt.Printf("player %d: %s\n", i+1, p.FormatForTerminal()) } time.Sleep(2 * time.Second) fmt.Printf("##############################################\n") // deal the flop var community pokercore.Cards community = d.Deal(3) fmt.Printf("flop: %s\n", community.FormatForTerminal()) time.Sleep(sleepTime) fmt.Printf("##############################################\n") turn := d.Deal(1) fmt.Printf("turn: %s\n", turn.FormatForTerminal()) community = append(community, turn...) fmt.Printf("board is now: %s\n", community.FormatForTerminal()) time.Sleep(sleepTime) fmt.Printf("##############################################\n") river := d.Deal(1) fmt.Printf("river: %s\n", river.FormatForTerminal()) community = append(community, river...) fmt.Printf("board is now: %s\n", community.FormatForTerminal()) fmt.Printf("##############################################\n") var winningPlayer int var winningHand *pokercore.PokerHand for i, p := range players { fmt.Printf("player %d: %s\n", i+1, p.FormatForTerminal()) playerCards, err := p.Append(community).IdentifyBestFiveCardPokerHand() if err != nil { panic("error evaluating hand: " + err.Error()) } ph, err := playerCards.PokerHand() if err != nil { panic("error evaluating hand: " + err.Error()) } fmt.Printf("player %d has a %s\n", i+1, ph.Description()) if winningHand == nil { winningPlayer = i winningHand = ph continue } if ph.Score > winningHand.Score { winningPlayer = i winningHand = ph } } fmt.Printf("##############################################\n") fmt.Printf("player %d wins with %s\n", winningPlayer+1, winningHand.Description()) fmt.Printf("##############################################\n") fmt.Printf("What a strange game. The only winning move is to bet really big.\n") fmt.Printf("Insert coin to play again.\n") }