private List <BaseCell> Neighbours(BaseCell cell) { int startPosition = _cells.IndexOf(cell); List <BaseCell> neighbours = new List <BaseCell>(); for (int i = -1; i <= 1; i++) { for (int j = -1; j <= 1; j++) { int neighPosition = startPosition + i * _cols + j; if (ValidatePosition(startPosition, neighPosition)) { neighbours.Add(_cells[neighPosition]); } } } return(neighbours); }
public BaseCell RandomNeighbour(BaseCell startCell) { BaseCell cell = Neighbours(startCell).Filter().Random(); return(cell ?? startCell); }
public int RandomNeighbour(int startCell) { BaseCell cell = Neighbours(_cells[startCell]).Filter().Random(); return(cell == null ? startCell : _cells.IndexOf(cell)); }
public int IndexOf(BaseCell cell) { return(_cells.IndexOf(cell)); }