Exemple #1
0
        private Ant FindFastestAnt()
        {
            int   AntNr = 0;
            float WaLen = 0;

            for (int i = 0; i < m_Ants.Count; i++)
            {
                Ant a = (Ant)m_Ants[i];
                a.CalcAntRoute();
                float tmpRoute = a.Length;
                if (i > 0)
                {
                    if (tmpRoute < WaLen)
                    {
                        WaLen = tmpRoute;
                        AntNr = i;
                    }
                }
                else
                {
                    WaLen = tmpRoute;
                    AntNr = i;
                }
            }

            if (m_ShortestPath < 0)
            {
                m_ShortestPath = WaLen;
            }
            else
            {
                if (WaLen < m_ShortestPath)
                {
                    m_ShortestPath = WaLen;
                    m_FastestAnt   = AntNr;
                }
            }
            return((Ant)m_Ants[m_FastestAnt]);
        }