示例#1
0
    private void SequentialMutation()
    {
        m_MutationCount++;
        bool NodesStable = true;

        for (int x = m_LeftEdge; x <= m_RightEdge; x++)
        {
            for (int y = m_TopEdge; y >= m_BottomEdge; y--)
            {
                MazeNode Node = GetNode(x, y);

                int BlockedNeighbors = CountBlockedNeighbors(Node);

                if (Node.ExitCount == 0)
                {
                    if (BlockedNeighbors < m_MutationBlockThreshhold)
                    {
                        Node.AddExitList(GridPosition.AllExits);
                        NodesStable = false;
                    }
                }
                else
                {
                    if (BlockedNeighbors > m_MutationBlockThreshhold)
                    {
                        Node.ClearExits();
                        NodesStable = false;
                    }
                }
            }
        }

        // Mutation cycles are capped at 100 for sanity
        if (!NodesStable && (m_MutationCount < 100))
        {
            SequentialMutation();
        }
    }