core

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrRequestedTooManyBots = errors.New("requested too many bots")

Functions

This section is empty.

Types

type BotEngine added in v1.0.0

type BotEngine interface {
	Run(ctx context.Context) <-chan types.Direction
}

type BotOperator

type BotOperator interface {
	Run(ctx context.Context)
	Stop()
}

func NewBotOperator

func NewBotOperator(params *BotOperatorParams) BotOperator

type BotOperatorFactory added in v1.0.0

type BotOperatorFactory interface {
	New(gameId int) BotOperator
}

type BotOperatorParams added in v1.0.0

type BotOperatorParams struct {
	GameId    int
	Connector Connector
	BotEngine BotEngine
	Parser    Parser
	Rand      Rand
	Clock     utils.Clock
}

type Connector

type Connector interface {
	Connect(ctx context.Context, gameId int) (connect.Connection, error)
}

type Core

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

func NewCore

func NewCore(params *Params) *Core

func (*Core) GetState added in v1.0.0

func (c *Core) GetState(ctx context.Context) map[int]int

func (*Core) Run added in v1.0.0

func (c *Core) Run(ctx context.Context) <-chan struct{}

func (*Core) SetOne added in v1.0.0

func (c *Core) SetOne(ctx context.Context, gameId, bots int) (map[int]int, error)

func (*Core) SetState added in v1.0.0

func (c *Core) SetState(ctx context.Context, state map[int]int) (map[int]int, error)

type DijkstrasBotOperatorFactory added in v1.0.0

type DijkstrasBotOperatorFactory struct {
	Logger    *logrus.Entry
	Rand      Rand
	Connector Connector
	Clock     utils.Clock
}

func (*DijkstrasBotOperatorFactory) New added in v1.0.0

type Params added in v1.0.0

type Params struct {
	BotsLimit int
	BotOperatorFactory
	utils.Clock
	Storage
}

type Parser added in v1.0.0

type Parser interface {
	Parse(message []byte) error
}

type Rand added in v1.0.0

type Rand interface {
	Intn(n int) int
}

type Storage added in v1.0.0

type Storage interface {
	Load(ctx context.Context) (map[int]int, error)
	Save(ctx context.Context, state map[int]int) error
	Type() string
}

func NewStorage added in v1.0.0

func NewStorage(fs afero.Fs, cfg config.Storage) Storage

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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