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 ¶
ReadPlayerAction returns the next action that the AI Client wants to apply on the game.
func (*Client) WritePlayerEvent ¶
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.