class BattleSnake::Board

Overview

Represents the Board as it arrives from the BattleSnake API endpoint.

@snake_points is an Array(BattleSnake::Point) variable populated when a Board is initialized and contains all the Points that are currently occupied by a snake (would represent a collision).

Included Modules

Defined in:

battle_snake/board.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(pull : JSON::PullParser) #

[View source]

Instance Method Detail

def after_initialize #

[View source]
def find_snake_points #

Executed on #after_initialize callback and all it does is populate snake_points variable (Array(Point)) with all points that belong to a snake on the board


[View source]
def food : Array(Point) #

[View source]
def food=(food : Array(Point)) #

[View source]
def hazards : Array(Point) #

[View source]
def hazards=(hazards : Array(Point)) #

[View source]
def height : Int32 #

[View source]
def height=(height : Int32) #

[View source]
def living?(id) #

Returns true if a snake id passed as parameter is alive on the board, returns false otherwise.


[View source]
def snake_points : Array(Point) #

[View source]
def snakes : Array(Snake) #

[View source]
def snakes=(snakes : Array(Snake)) #

[View source]
def width : Int32 #

[View source]
def width=(width : Int32) #

[View source]