Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( Direction_Up = Direction{0, 1} Direction_Down = Direction{0, -1} Direction_Left = Direction{-1, 0} Direction_Right = Direction{1, 0} )
View Source
var DirectionToMove = map[Direction]BattlesnakeMove{ Direction_Down: BattlesnakeMove_Down, Direction_Up: BattlesnakeMove_Up, Direction_Left: BattlesnakeMove_Left, Direction_Right: BattlesnakeMove_Right, }
View Source
var MoveToDirection = map[BattlesnakeMove]Direction{ BattlesnakeMove_Down: Direction_Down, BattlesnakeMove_Up: Direction_Up, BattlesnakeMove_Left: Direction_Left, BattlesnakeMove_Right: Direction_Right, }
Functions ¶
func CoordSliceContains ¶
CoordSliceContains returns back whether elem is contained in slice
Types ¶
type Battlesnake ¶
type Battlesnake struct { ID string `json:"id"` Name string `json:"name"` Health int32 `json:"health"` Body []Coord `json:"body"` Head Coord `json:"head"` Length int32 `json:"length"` Latency string `json:"latency"` // Used in non-standard game modes Shout string `json:"shout"` Squad string `json:"squad"` }
func (Battlesnake) Direction ¶
func (snake Battlesnake) Direction() Direction
func (Battlesnake) Next ¶
func (snake Battlesnake) Next(dir Direction, board Board) Battlesnake
Next returns back a new slice of coordinates the represents the new snake body If addOne is `true` then the body has an additional segment
type BattlesnakeInfoResponse ¶
type BattlesnakeMove ¶
type BattlesnakeMove string
const ( BattlesnakeMove_Up BattlesnakeMove = "up" BattlesnakeMove_Down BattlesnakeMove = "down" BattlesnakeMove_Left BattlesnakeMove = "left" BattlesnakeMove_Right BattlesnakeMove = "right" )
type BattlesnakeMoveResponse ¶
type BattlesnakeMoveResponse struct { Move BattlesnakeMove `json:"move"` Shout string `json:"shout,omitempty"` }
type Board ¶
type Board struct { Height int `json:"height"` Width int `json:"width"` Food []Coord `json:"food"` Snakes []Battlesnake `json:"snakes"` // Used in non-standard game modes Hazards []Coord `json:"hazards"` // contains filtered or unexported fields }
func (Board) Occupied ¶
Occupied returns back true if regardless of any movement if the coordinate will be occupied by a hazard or a snake body
func (Board) OtherSnakes ¶
func (b Board) OtherSnakes(myID string) []Battlesnake
func (Board) OutOfBounds ¶
type Coord ¶
func (Coord) Add ¶
Add gets the sum of the individual axis of this coordinate and another: {x1 + x2, y1 + y2}
func (Coord) Euclidean ¶
Euclidean calculates the euclidean (actual) distance: ((x2 - x1)^2) + (y2 - y1)^2)^0.5
type CoordComparator ¶
Click to show internal directories.
Click to hide internal directories.