bot

package
v0.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 6, 2024 License: GPL-3.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SelfPlayer = 0
	BotPlayer  = 1
)
View Source
const (
	StarPlayThreshold = 10.0 // equity
)
View Source
const WolgesTimeout = 5 * time.Second

Variables

View Source
var (
	ErrNeedSimmingBot = errors.New("need simming bot")
)

Functions

func Main

func Main(channel string, bot *Bot)

Main implements a NATS listener that takes data from a channel. It does not respond on a reply channel, because that implies the caller would need to block and wait for a response. Instead, we must send a bot move on a separate per-game-id channel when ready.

func MakeRequest

func MakeRequest(game *bot.BotTurnPlayer, cfg *config.Config) ([]byte, error)

Types

type Bot

type Bot struct {
	// contains filtered or unexported fields
}

func NewBot

func NewBot(cfg *mcfg.Config, options *turnplayer.GameOptions) *Bot

func (*Bot) Deserialize

func (bot *Bot) Deserialize(data []byte) (*game.Game, *pb.BotRequest, error)

type Client

type Client struct {
	// contains filtered or unexported fields
}

func (*Client) RequestMove

func (c *Client) RequestMove(game *bot.BotTurnPlayer, config *config.Config) (*move.Move, error)

Send a game to the bot and get a move back.

type LambdaEvent added in v0.8.6

type LambdaEvent struct {
	CGP          string `json:"cgp"`
	BotType      int    `json:"botType"`
	ReplyChannel string `json:"replyChannel"`
	GameID       string `json:"gameId"`
}

type Response

type Response struct {
	// contains filtered or unexported fields
}

func Msg

func Msg(message string) *Response

func Send

func Send(message string) *Response

Keep Send in case we need bot debug messages, but for regular bot-to-play the shell now automatically sends a message.

type ShellController

type ShellController struct {
	// contains filtered or unexported fields
}

func NewShellController

func NewShellController(cfg *config.Config, execPath string) *ShellController

func (*ShellController) IsBotOnTurn

func (sc *ShellController) IsBotOnTurn() bool

func (*ShellController) IsPlaying

func (sc *ShellController) IsPlaying() bool

func (*ShellController) Loop

func (sc *ShellController) Loop(channel string, sig chan os.Signal)

type ShellOptions

type ShellOptions struct {
	turnplayer.GameOptions
	// contains filtered or unexported fields
}

Options to configure the interactve shell

func NewShellOptions

func NewShellOptions() *ShellOptions

func (*ShellOptions) Show

func (opts *ShellOptions) Show(key string) (bool, string)

func (*ShellOptions) ToDisplayText

func (opts *ShellOptions) ToDisplayText() string

type WolgesAnalyzePayload added in v0.4.9

type WolgesAnalyzePayload struct {
	Rack    []int   `json:"rack"`
	Board   [][]int `json:"board"`
	Lexicon string  `json:"lexicon"`
	Leave   string  `json:"leave"`
	Rules   string  `json:"rules"`
	Count   int     `json:"count"`
}

type WolgesAnalyzeResponse added in v0.4.9

type WolgesAnalyzeResponse struct {
	Equity float32 `json:"equity"`
	Action string  `json:"action"`
	Tiles  []int   `json:"tiles"` // used for exchange. If empty it is a pass.
	Down   bool    `json:"down"`
	Lane   int     `json:"lane"`
	Idx    int     `json:"idx"`
	Word   []int   `json:"word"`
	Score  int     `json:"score"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL