Added documentation
This commit is contained in:
@@ -9,11 +9,18 @@ import (
|
||||
"bitbucket.org/hackerbots/vector"
|
||||
)
|
||||
|
||||
// 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 Player interface {
|
||||
Recv(bs *botserv.Boardstate)
|
||||
Instruction() map[string]botserv.Instruction
|
||||
}
|
||||
|
||||
// SimplePlayer is our default player and stands as a starting point for your
|
||||
// own Player implementations.
|
||||
type SimplePlayer struct {
|
||||
me botserv.Robot
|
||||
width, height float32
|
||||
@@ -26,6 +33,7 @@ type SimplePlayer struct {
|
||||
safeDistance float32
|
||||
}
|
||||
|
||||
// NewSimplePlayer simply returns a populated, usable *SimplePlayer
|
||||
func NewSimplePlayer(width, height float32) *SimplePlayer {
|
||||
return &SimplePlayer{
|
||||
knownObstacles: make(map[string]botserv.Obstacle),
|
||||
@@ -36,6 +44,7 @@ func NewSimplePlayer(width, height float32) *SimplePlayer {
|
||||
}
|
||||
}
|
||||
|
||||
// Recv is our implementation of receiving a botserv.Boardstate from the server
|
||||
func (p *SimplePlayer) Recv(bs *botserv.Boardstate) {
|
||||
p.speed = p.maxSpeed
|
||||
if len(bs.MyRobots) > 0 {
|
||||
@@ -98,6 +107,8 @@ func (p *SimplePlayer) recon(bs *botserv.Boardstate) {
|
||||
}
|
||||
}
|
||||
|
||||
// Instruction is our default implementation of preparing a map of information
|
||||
// to be sent to server.
|
||||
func (p *SimplePlayer) Instruction() map[string]botserv.Instruction {
|
||||
return map[string]botserv.Instruction{
|
||||
p.me.Id: {
|
||||
@@ -149,7 +160,7 @@ func (mo MiniObstacle) String() string {
|
||||
return mo.Id()
|
||||
}
|
||||
|
||||
// toObstacle is where the conversion magic happens
|
||||
// ToObstacle is where the conversion magic happens
|
||||
func (mo *MiniObstacle) ToObstacle() botserv.Obstacle {
|
||||
return botserv.Obstacle{
|
||||
Bounds: govector.AABB2d{
|
||||
|
||||
Reference in New Issue
Block a user