client

package module
v0.0.0-...-f9984c1 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2016 License: BSD-3-Clause Imports: 11 Imported by: 0

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) Negotiate

func (c *Client) Negotiate(clientType string, player Player) (err error)

Negotiate runs through the hackerbots negociation protocol.

func (*Client) Play

func (c *Client) Play() error

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

func (*Client) Visualize

func (s *Client) Visualize()

type Fraserbot

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

Fraserbot is a bad ass motherfucker, that will fuck SHIT UUUUUP

func NewFraserbot

func NewFraserbot(name string) *Fraserbot

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) SetIDs

func (p *Fraserbot) SetIDs(ids map[string]string)

SetIDs provides the mapping of names to ID's for each bot

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

Update is our implementation of recieving and processing a server.Boardstate from the server

type Spectator

type Spectator struct{}

func (Spectator) GetStats

func (s Spectator) GetStats() map[string]server.StatsRequest

func (Spectator) SetIDs

func (s Spectator) SetIDs(map[string]string)

func (Spectator) Update

func (s Spectator) Update(bs *server.Boardstate) map[string]server.Instruction

Directories

Path Synopsis
cmd
botspectate command
gobot command

Jump to

Keyboard shortcuts

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