-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCell.cs
More file actions
29 lines (26 loc) · 858 Bytes
/
Cell.cs
File metadata and controls
29 lines (26 loc) · 858 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
namespace GameOfLife
{
public struct Cell
{
public int col;
public int row;
public Cell(int columnIndex, int rowIndex)
{
this.col = columnIndex;
this.row = rowIndex;
}
public readonly Cell[] GetNeighborCells()
{
Cell[] neighborCells = new Cell[8];
neighborCells[0] = new Cell(col - 1, row - 1);
neighborCells[1] = new Cell(col - 1, row);
neighborCells[2] = new Cell(col - 1, row + 1);
neighborCells[3] = new Cell(col, row - 1);
neighborCells[4] = new Cell(col, row + 1);
neighborCells[5] = new Cell(col + 1, row - 1);
neighborCells[6] = new Cell(col + 1, row);
neighborCells[7] = new Cell(col + 1, row + 1);
return neighborCells;
}
}
}