parent
fc3f94e78f
commit
7567f1c991
@ -1,12 +1,12 @@
|
||||
package conway
|
||||
|
||||
type GameStateCell struct {
|
||||
Value int
|
||||
X int
|
||||
Y int
|
||||
cols []int
|
||||
Value int
|
||||
X int
|
||||
Y int
|
||||
cellmates []int
|
||||
}
|
||||
|
||||
func (cell *GameStateCell) SetValue(value int) {
|
||||
cell.cols[cell.X] = value
|
||||
cell.cellmates[cell.X] = value
|
||||
}
|
||||
|
@ -0,0 +1,21 @@
|
||||
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,
|
||||
}
|
||||
}
|
Loading…
Reference in new issue