private void TryRun( GridSystem result, int level) { if (!result.System.ContainsKey(level)) { var above = System.ContainsKey(level + 1) ? System[level + 1] : EMPTY_LEVEL; var below = System.ContainsKey(level - 1) ? System[level - 1] : EMPTY_LEVEL; var curr = System.ContainsKey(level) ? System[level] : EMPTY_LEVEL; result.System[level] = curr.RunMinute(above, below); } }
public GridSystem RunMinute() { var result = new GridSystem(); foreach (var level in System.Keys) { TryRun(result, level); TryRun(result, level + 1); TryRun(result, level - 1); } return(result); }