don't rename package without need.
This commit is contained in:
@@ -5,7 +5,7 @@ import (
|
||||
"math"
|
||||
"math/rand"
|
||||
|
||||
hbserver "bitbucket.org/hackerbots/server"
|
||||
"bitbucket.org/hackerbots/server"
|
||||
"bitbucket.org/hackerbots/vector"
|
||||
)
|
||||
|
||||
@@ -15,17 +15,17 @@ import (
|
||||
// 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 *hbserver.Boardstate)
|
||||
Instruction() map[string]hbserver.Instruction
|
||||
Recv(bs *server.Boardstate)
|
||||
Instruction() map[string]server.Instruction
|
||||
}
|
||||
|
||||
// SimplePlayer is our default player and stands as a starting point for your
|
||||
// own Player implementations.
|
||||
type SimplePlayer struct {
|
||||
me hbserver.Robot
|
||||
me server.Robot
|
||||
width, height float32
|
||||
knownObstacles map[string]hbserver.Obstacle
|
||||
nearestEnemy *hbserver.OtherRobot
|
||||
knownObstacles map[string]server.Obstacle
|
||||
nearestEnemy *server.OtherRobot
|
||||
fireat *vector.Point2d
|
||||
moveto *vector.Point2d
|
||||
speed float32
|
||||
@@ -36,7 +36,7 @@ type SimplePlayer struct {
|
||||
// NewSimplePlayer simply returns a populated, usable *SimplePlayer
|
||||
func NewSimplePlayer(width, height float32) *SimplePlayer {
|
||||
return &SimplePlayer{
|
||||
knownObstacles: make(map[string]hbserver.Obstacle),
|
||||
knownObstacles: make(map[string]server.Obstacle),
|
||||
width: width,
|
||||
height: height,
|
||||
maxSpeed: 100,
|
||||
@@ -44,8 +44,8 @@ func NewSimplePlayer(width, height float32) *SimplePlayer {
|
||||
}
|
||||
}
|
||||
|
||||
// Recv is our implementation of receiving a hbserver.Boardstate from the server
|
||||
func (p *SimplePlayer) Recv(bs *hbserver.Boardstate) {
|
||||
// Recv is our implementation of receiving a server.Boardstate from the server
|
||||
func (p *SimplePlayer) Recv(bs *server.Boardstate) {
|
||||
p.speed = p.maxSpeed
|
||||
if len(bs.MyRobots) > 0 {
|
||||
p.me = bs.MyRobots[0]
|
||||
@@ -81,7 +81,7 @@ func (p *SimplePlayer) navigate() {
|
||||
}
|
||||
}
|
||||
|
||||
func (p *SimplePlayer) recon(bs *hbserver.Boardstate) {
|
||||
func (p *SimplePlayer) recon(bs *server.Boardstate) {
|
||||
for _, o := range bs.Objects {
|
||||
obj := MiniObstacle(o)
|
||||
if _, ok := p.knownObstacles[obj.Id()]; !ok {
|
||||
@@ -109,8 +109,8 @@ func (p *SimplePlayer) recon(bs *hbserver.Boardstate) {
|
||||
|
||||
// Instruction is our default implementation of preparing a map of information
|
||||
// to be sent to server.
|
||||
func (p *SimplePlayer) Instruction() map[string]hbserver.Instruction {
|
||||
return map[string]hbserver.Instruction{
|
||||
func (p *SimplePlayer) Instruction() map[string]server.Instruction {
|
||||
return map[string]server.Instruction{
|
||||
p.me.Id: {
|
||||
MoveTo: p.moveto,
|
||||
TargetSpeed: &p.speed,
|
||||
@@ -142,7 +142,7 @@ func (p *SimplePlayer) probe(destination vector.Point2d) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// MiniObstacle is a convenient way to encode/decode between the [4]int -> hbserver.Obstacle
|
||||
// MiniObstacle is a convenient way to encode/decode between the [4]int -> server.Obstacle
|
||||
type MiniObstacle [4]int
|
||||
|
||||
// id is used to calculate a key for use in maps
|
||||
@@ -161,8 +161,8 @@ func (mo MiniObstacle) String() string {
|
||||
}
|
||||
|
||||
// ToObstacle is where the conversion magic happens
|
||||
func (mo *MiniObstacle) ToObstacle() hbserver.Obstacle {
|
||||
return hbserver.Obstacle{
|
||||
func (mo *MiniObstacle) ToObstacle() server.Obstacle {
|
||||
return server.Obstacle{
|
||||
Bounds: vector.AABB2d{
|
||||
A: vector.Point2d{float32(mo[0]), float32(mo[1])},
|
||||
B: vector.Point2d{float32(mo[2]), float32(mo[3])},
|
||||
|
||||
Reference in New Issue
Block a user