ai

package
v0.0.0-...-2379a7f Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client is an "ai" controlled client that listens for game events and produces actions in response. The actions are chosen by the selected strategy.

func NewClient

func NewClient(log *logrus.Logger, strategyCreator StrategyCreatorFunc) (*Client, error)

NewClient creates a new AI Client using the provided strategy.

func (*Client) Disconnect

func (c *Client) Disconnect()

Disconnect disconnects the Client, closing the DisconnectCh and unblocking and Read calls.

func (*Client) DisconnectCh

func (c *Client) DisconnectCh() <-chan struct{}

DisconnectCh returns a channel closed when the Client is disconnected. For the AI Client, this channel is only closed as a result of a call to Disconnect.

func (*Client) ReadPlayerAction

func (c *Client) ReadPlayerAction(ctx context.Context) (model.PlayerAction, error)

ReadPlayerAction returns the next action that the AI Client wants to apply on the game.

func (*Client) WritePlayerEvent

func (c *Client) WritePlayerEvent(ctx context.Context, playerEvent model.PlayerEvent) error

WritePlayerEvent "writes" a player event to the AI Client, which will be used to produce new actions by the client.

type StrategyCreatorFunc

type StrategyCreatorFunc func() (strategy, error)

StrategyCreatorFunc is a function that returns an AI strategy, hiding the strategy interface.

func OpportunisticStrategy

func OpportunisticStrategy() StrategyCreatorFunc

OpportunisticStrategy tries to launch airplanes only to islands that it can conquer.

func RandomStrategy

func RandomStrategy(minOriginStrength int64) StrategyCreatorFunc

RandomStrategy launches airplanes at (mostly) random.

Jump to

Keyboard shortcuts

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