Exemplo n.º 1
0
        //implements a two cycle map
        private int AssignStacksToAgents()
        {
            //first we create a cycle of all but one
            m_lAgentStacks = new List <List <int> >();
            int        iCurrentStack = 0;
            bool       bSmallAgent   = false;
            List <int> lStacks       = null;

            for (int i = 0; i < Arms - 1; i++)
            {
                double dRand = RandomGenerator.NextDouble();
                bSmallAgent = dRand < 0.0;

                int cStacks = 0;
                if (bSmallAgent)
                {
                    cStacks = RandomGenerator.Next(2) + 3;
                }
                else
                {
                    cStacks = RandomGenerator.Next(MaxStacksPerAgent / 2) + MaxStacksPerAgent / 2 + 3;
                }
                lStacks = new List <int>();
                for (int j = 0; j < cStacks; j++)
                {
                    lStacks.Add(iCurrentStack + j);
                }
                m_lAgentStacks.Add(lStacks);
                iCurrentStack += cStacks - 1;
            }
            m_lAgentStacks.Last().Add(0);
            int iConnectStack1 = RandomGenerator.Next(iCurrentStack / 2);
            int iConnectStack2 = RandomGenerator.Next(iCurrentStack / 2) + iCurrentStack / 2;


            //now we cut the cycle in half
            lStacks = new List <int>();
            lStacks.Add(iConnectStack1);
            lStacks.Add(iCurrentStack + 1);
            lStacks.Add(iConnectStack2);
            m_lAgentStacks.Add(lStacks);

            m_lPublicStacks = new List <int>();
            for (int iStack = 0; iStack < iCurrentStack + 1; iStack++)
            {
                int cReachingArms = 0;
                foreach (List <int> l in m_lAgentStacks)
                {
                    if (l.Contains(iStack))
                    {
                        cReachingArms++;
                    }
                }
                if (cReachingArms > 1)
                {
                    m_lPublicStacks.Add(iStack);
                }
            }


            return(iCurrentStack + 2);
        }