Documentation
¶
Overview ¶
client is a package used to connect to and interact with a hackebots game.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { ForceJSON bool GameId string Name string Server string Game server.GameParam StateStream chan *server.Boardstate Die chan struct{} Player // contains filtered or unexported fields }
Client keeps track of connection to server and has two interesting methods: Negotiate and Play. Users of this struct will likely use most everything as is while defining their own Player to specify desired game play behavior.
func (*Client) Play ¶
Play contains the main game run loop. It gets a server.Boardstate from the server, and passes this along to the embedded Player. Following this it sends the server the Player's instruction.
func (*Client) Recv ¶
func (s *Client) Recv(bs *server.Boardstate) map[string]server.Instruction
Recv is our implementation of receiving a server.Boardstate from the server
type Fraserbot ¶
type Fraserbot struct {
// contains filtered or unexported fields
}
Fraserbot is a bad ass motherfucker, that will fuck SHIT UUUUUP
func NewFraserbot ¶
NewFraserbot simply returns a populated, usable *Fraserbot
func (*Fraserbot) GetStats ¶
func (p *Fraserbot) GetStats() map[string]server.StatsRequest
GetStats returns a map with an entry for each robot the player will control containing the desired stats for that robot
func (*Fraserbot) Update ¶
func (p *Fraserbot) Update(bs *server.Boardstate) map[string]server.Instruction
Update is our implementation of recieving and processing a server.Boardstate from the server
type Player ¶
type Player interface { // GetStats returns a map with an entry for each robot the player will control // containing the desired stats for that robot GetStats() map[string]server.StatsRequest // SetIDs is called from the client once the server // has accepted the robots supplied in GetStats and validated // their config, the data passed into SetIDs is a mapping of // bot name to server side bot ID that is used in all bot // dats sent from the server SetIDs(map[string]string) // Update is called on reciept of a board state packet and the response is // the instructions for each robot in a map of robot id to instructions Update(bs *server.Boardstate) map[string]server.Instruction }
Player is the interface that is implemented when specifying non-default player behavior.
The general case will be to implement a Player type that contains the magic required to slay other robots quickly while staying alive for a long time.
type SimplePlayer ¶
type SimplePlayer struct {
// contains filtered or unexported fields
}
SimplePlayer is our default player and stands as a starting point for your own Player implementations.
func NewSimplePlayer ¶
func NewSimplePlayer(width, height float64, stats server.StatsRequest) *SimplePlayer
NewSimplePlayer simply returns a populated, usable *SimplePlayer
func (*SimplePlayer) GetStats ¶
func (p *SimplePlayer) GetStats() map[string]server.StatsRequest
GetStats returns a map with an entry for each robot the player will control containing the desired stats for that robot
func (*SimplePlayer) Instruction ¶
func (p *SimplePlayer) Instruction() map[string]server.Instruction
Instruction is our default implementation of preparing a map of information to be sent to server.
func (*SimplePlayer) SetIDs ¶
func (p *SimplePlayer) SetIDs(map[string]string)
func (*SimplePlayer) Update ¶
func (p *SimplePlayer) Update(bs *server.Boardstate) map[string]server.Instruction
Update is our implementation of recieving and processing a server.Boardstate from the server
type Spectator ¶
type Spectator struct{}
func (Spectator) Update ¶
func (s Spectator) Update(bs *server.Boardstate) map[string]server.Instruction