Exemplo n.º 1
0
        private static void ProcessCell(CellCollection run, Cell cell)
        {
            if ((run == null) || (cell == null))
            {
                return;
            }

            run.Add(cell);

            bool atEasterBoundary   = cell.East == null;
            bool atNorthernBoundary = cell.North == null;

            bool shouldCloseOut = atEasterBoundary ||
                                  (!atNorthernBoundary && rnd.Next(2) == 0);

            if (shouldCloseOut)
            {
                Cell member = run.Sample();
                if (member.North != null)
                {
                    member.Link(member.North);
                }

                run.Clear();
            }
            else
            {
                cell.Link(cell.East);
            }
        }