/// <summary> /// By applying game rules get the next genertion grid instance /// </summary> /// <param name="currentGrid"> Grid on which games rules </param> /// <param name="gameRules"> </param> /// <returns> Evolved grid instance </returns> public IGrid GetNextGeneration(IGrid currentGrid, IGameRules gameRules) { if (currentGrid != null && gameRules != null) { var gridCopy = currentGrid.Copy(currentGrid); foreach (var cell in currentGrid.GetAllCurrentCellInfo()) { cell.Alive = gameRules.WillBeAliveInNextGeneration(gridCopy, cell); gridCopy.MakeCell(cell); } return gridCopy; } return null; }