box-o-sand/conway/game_state_row.go

22 lines
332 B
Go
Raw Normal View History

package conway
type GameStateRow struct {
Y int
Cells []int
}
func (row *GameStateRow) GetCell(x int) *GameStateCell {
lenCells := len(row.Cells)
if x+1 > lenCells {
return row.GetCell(x % lenCells)
}
return &GameStateCell{
Value: row.Cells[x],
X: x,
Y: row.Y,
cellmates: row.Cells,
}
}