initial commit
This commit is contained in:
commit
ac9aa86d33
14 changed files with 1021 additions and 0 deletions
30
internal/game/bot.go
Normal file
30
internal/game/bot.go
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
package game
|
||||
|
||||
import "math/rand"
|
||||
|
||||
type Bot struct {
|
||||
Player
|
||||
}
|
||||
|
||||
func NewBot(id, name string) *Bot {
|
||||
return &Bot{
|
||||
Player: *NewPlayer(id, name),
|
||||
}
|
||||
}
|
||||
|
||||
func (b *Bot) ChooseRank(hand []Card) Rank {
|
||||
// Bot simply picks a random card rank from its hand
|
||||
if len(hand) == 0 {
|
||||
return RankAce
|
||||
}
|
||||
idx := rand.Intn(len(hand))
|
||||
return hand[idx].Rank
|
||||
}
|
||||
|
||||
func (b *Bot) ChooseCardToAsk(availableRanks []Rank) Rank {
|
||||
if len(availableRanks) > 0 {
|
||||
idx := rand.Intn(len(availableRanks))
|
||||
return availableRanks[idx]
|
||||
}
|
||||
return RankAce
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue