client

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2020 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Code generated by gen_client. DO NOT EDIT.

Index

Constants

This section is empty.

Variables

View Source
var MaxMessageSize = 2 * 1024 * 1024

MaxMessageSize is the largest protobuf message that can be sent without getting disconnected. The gorilla/websocket implementation fragments messages above it's write buffer size and the SC2 game doesn't seem to be able to deal with these messages. There is not a check in place to prevent large messages from being sent and warnings will be printed if a message size exceeds half of this limit. The default is now 2MB (up from 4kb) but can be overrided by modifying this value before connecting to SC2.

Functions

func ReportPanic

func ReportPanic(p interface{})

ReportPanic ...

Types

type Agent

type Agent interface {
	RunAgent(AgentInfo)
}

Agent ...

type AgentFunc

type AgentFunc func(AgentInfo)

AgentFunc ...

func (AgentFunc) RunAgent

func (f AgentFunc) RunAgent(info AgentInfo)

RunAgent ...

type AgentInfo

type AgentInfo interface {
	IsRealtime() bool

	PlayerID() api.PlayerID
	GameInfo() *api.ResponseGameInfo
	ReplayInfo() *api.ResponseReplayInfo
	Data() *api.ResponseData
	Observation() *api.ResponseObservation
	Upgrades() []api.UpgradeID
	HasUpgrade(upgrade api.UpgradeID) bool

	IsInGame() bool
	Step(stepSize int) error

	Query(query api.RequestQuery) *api.ResponseQuery
	SendActions(actions []*api.Action) []api.ActionResult
	SendObserverActions(obsActions []*api.ObserverAction)
	SendDebugCommands(commands []*api.DebugCommand)
	ClearDebugDraw()
	LeaveGame()

	OnBeforeStep(func())
	OnObservation(func())
	OnAfterStep(func())

	SetPerfInterval(steps uint32)
}

AgentInfo ...

type Client

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

Client ...

func (*Client) ClearDebugDraw

func (c *Client) ClearDebugDraw()

ClearDebugDraw sends an empty draw command if previous draw commands have been sent

func (*Client) Connect

func (c *Client) Connect(address string, port int, timeout time.Duration) error

Connect ...

func (*Client) CreateGame

func (c *Client) CreateGame(mapPath string, players []*api.PlayerSetup, realtime bool) error

CreateGame ...

func (*Client) Data

func (c *Client) Data() *api.ResponseData

Data ...

func (*Client) GameInfo

func (c *Client) GameInfo() *api.ResponseGameInfo

GameInfo ...

func (*Client) GetObservation

func (c *Client) GetObservation() (*api.ResponseObservation, error)

GetObservation ...

func (*Client) HasUpgrade

func (c *Client) HasUpgrade(upgrade api.UpgradeID) bool

HasUpgrade ...

func (*Client) Init

func (c *Client) Init() error

Init ...

func (*Client) IsInGame

func (c *Client) IsInGame() bool

IsInGame ...

func (*Client) IsRealtime

func (c *Client) IsRealtime() bool

IsRealtime returns true if the bot was launched in realtime mode.

func (*Client) LeaveGame

func (c *Client) LeaveGame()

LeaveGame ...

func (*Client) Observation

func (c *Client) Observation() *api.ResponseObservation

Observation ...

func (*Client) OnAfterStep

func (c *Client) OnAfterStep(callback func())

OnAfterStep ...

func (*Client) OnBeforeStep

func (c *Client) OnBeforeStep(callback func())

OnBeforeStep ...

func (*Client) OnObservation

func (c *Client) OnObservation(callback func())

OnObservation is called after every observation. This is generally equivalent to OnAfterStep except in realtime mode when multiple observations may occur to reach the desired step size. This can be used to observe transient data that only appears in a single observation (actions, events, chat, etc).

func (*Client) PlayerID

func (c *Client) PlayerID() api.PlayerID

PlayerID ...

func (*Client) Proto

func (c *Client) Proto() api.ResponsePing

Proto ...

func (*Client) Query

func (c *Client) Query(query api.RequestQuery) *api.ResponseQuery

Query ...

func (*Client) ReplayInfo

func (c *Client) ReplayInfo() *api.ResponseReplayInfo

ReplayInfo ...

func (*Client) RequestJoinGame

func (c *Client) RequestJoinGame(setup *api.PlayerSetup, options *api.InterfaceOptions, ports Ports) error

RequestJoinGame ...

func (*Client) RequestLeaveGame

func (c *Client) RequestLeaveGame() error

RequestLeaveGame ...

func (*Client) RequestReplayInfo

func (c *Client) RequestReplayInfo(path string) (*api.ResponseReplayInfo, error)

RequestReplayInfo ...

func (*Client) RequestStartReplay

func (c *Client) RequestStartReplay(request api.RequestStartReplay) error

RequestStartReplay ...

func (*Client) SendActions

func (c *Client) SendActions(actions []*api.Action) []api.ActionResult

SendActions ...

func (*Client) SendDebugCommands

func (c *Client) SendDebugCommands(commands []*api.DebugCommand)

SendDebugCommands ...

func (*Client) SendObserverActions

func (c *Client) SendObserverActions(obsActions []*api.ObserverAction)

SendObserverActions ...

func (*Client) SetPerfInterval

func (c *Client) SetPerfInterval(steps uint32)

SetPerfInterval determines how often perfornace data will be updated. Values less than or equal to 0 will disable display (defalts to zero).

func (*Client) SetProcessInfo

func (c *Client) SetProcessInfo(pi ProcessInfo)

SetProcessInfo ...

func (*Client) Step

func (c *Client) Step(stepSize int) error

Step ...

func (*Client) TryConnect

func (c *Client) TryConnect(address string, port int) error

TryConnect ...

func (*Client) Upgrades

func (c *Client) Upgrades() []api.UpgradeID

Upgrades ...

type PlayerSetup

type PlayerSetup struct {
	*api.PlayerSetup
	Agent
}

PlayerSetup ...

func NewComputer

func NewComputer(race api.Race, difficulty api.Difficulty, build api.AIBuild) PlayerSetup

NewComputer ...

func NewObserver

func NewObserver(agent Agent, name string) PlayerSetup

NewObserver ...

func NewParticipant

func NewParticipant(race api.Race, agent Agent, name string) PlayerSetup

NewParticipant ...

type Ports

type Ports struct {
	ServerPorts *api.PortSet
	ClientPorts []*api.PortSet
	SharedPort  int32
}

Ports ...

type ProcessInfo

type ProcessInfo struct {
	Path string
	PID  int
	Port int
}

ProcessInfo ...

Jump to

Keyboard shortcuts

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