Documentation ¶
Index ¶
Constants ¶
const ( // MinWidth is the minimum width for a grid. MinWidth = 3 // MinHeight is the minimum height for a grid. MinHeight = 3 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Grid ¶
type Grid struct {
// contains filtered or unexported fields
}
Grid represents a snapshot of a universe. The zero value of this type is not safe, use the function New below. The minimum width and height for a universe is 3 cells each.
func New ¶
New creates a new grid with the given width and height (number of cells) and the given list of alive cells. The grid has its origin of coordinates at the upper left corner. Returns an error if the width or the height are smaller than MinWidth and MinHeight or if any of the alive cells are out of bounds.
func NewRandom ¶
NewRandom returns a grid with n random alive cells inside a grid with the given dimensions.
func (*Grid) Height ¶
Height returns the height of the universe (number of cells). Implements conway.Grid.