Пример #1
0
        public static void CreateBeesTest(int scoutCount, Site site) 
        {
            scoutBees.Clear();

            Bee.State[] states = { Bee.State.EXPLORING, Bee.State.OBSERVING, Bee.State.RESTING, Bee.State.ASSESSING, Bee.State.DANCING };

            //            R   O   E   A   D
            int[] test = {20, 20, 60, 0, 0};

            for (int i = 0; i < test[0]; i++) {
                Bee newBee = new Bee(Constants.DESTINATION_RADIUS, rand, Bee.State.EXPLORING);
                scoutBees.Add(newBee);
            }
            for (int i = 0; i < test[1]; i++) {
                Bee newBee = new Bee(Constants.DESTINATION_RADIUS, rand, Bee.State.OBSERVING);
                scoutBees.Add(newBee);
            }
            for (int i = 0; i < test[2]; i++) {
                Bee newBee = new Bee(Constants.DESTINATION_RADIUS, rand, Bee.State.RESTING);
                scoutBees.Add(newBee);
            }
            for (int i = 0; i < test[3]; i++) {
                Bee newBee = new Bee(Constants.DESTINATION_RADIUS, rand, Bee.State.ASSESSING);
                newBee.FoundSite(site);
                scoutBees.Add(newBee);
            }
            for (int i = 0; i < test[4]; i++) {
                Bee newBee = new Bee(Constants.DESTINATION_RADIUS, rand, Bee.State.DANCING);
                newBee.setSite(site);
                scoutBees.Add(newBee);
            }

        }
Пример #2
0
 /// <summary>
 /// Adds a new dancer's enthusiasum to the floor
 /// </summary>
 internal static void RemoveDancer(Bee b)
 {
     double quality = b.getSite().Quality;
     if (quality >= QualityThreshold)
     {
         dancers.Remove(b);
         --danceDistribution[quality];
         if (danceDistribution[quality] <= 0)
         {
             danceDistribution.Remove(quality);
         }
     }
 }
Пример #3
0
        /// <summary>
        /// Checks to see if the specified bee has discovered a potential nest site
        /// </summary>
        /// <param name="b">The bee we are currently checking</param>
        //private void CheckSearcher(Bee b) {
        //    foreach (Site s in potentialSites) {
        //        if (b.HasReachedDestination(s.Point)) {
        //            s.Visited = true;
        //            b.FoundSite(s);
        //        }
        //    }
        //}

        private void CheckSearcher(Bee b)
        {
            foreach (Site s in potentialSites)
            {
                if (!s.Visited && b.IsExploring())
                {
                    if (b.HasReachedDestination(s.Point))
                    {
                        s.Visited = true;
                        b.FoundSite(s);
                    }
                }
            }
        }
Пример #4
0
        /// <summary>
        /// Adds a new dancer's enthusiasum to the floor
        /// </summary>
        internal static void RemoveDancer(Bee b)
        {
            double quality = b.getSite().Quality;

            if (quality >= QualityThreshold)
            {
                dancers.Remove(b);
                --danceDistribution[quality];
                if (danceDistribution[quality] <= 0)
                {
                    danceDistribution.Remove(quality);
                }
            }
        }
Пример #5
0
        public static void CreateBees(int scoutCount)
        {
            scoutBees.Clear();

            int n = (int)(scoutCount * Constants.INITIAL_SEARCH_FRACTION);
            for (int i = 0; i < n; ++i)
            {
                Bee newBee = new Bee(Constants.DESTINATION_RADIUS, rand, Bee.State.EXPLORING);
                scoutBees.Add(newBee);
            }

            for (int i = 0; i < scoutCount * (1 - Constants.INITIAL_SEARCH_FRACTION); ++i)
            {
                scoutBees.Add(new Bee(Constants.DESTINATION_RADIUS, rand));
            }
        }
Пример #6
0
 /// <summary>
 /// Adds a new dancer's enthusiasum to the floor
 /// </summary>
 internal static void AddDancer(Bee b)
 {
     double quality = b.getSite().Quality;
     if (quality >= QualityThreshold)
     {
         if (!danceDistribution.ContainsKey(quality))
         {
             danceDistribution.Add(quality, 1);
         }
         else 
         {
             ++danceDistribution[quality];
         }
         dancers.Add(b);
     }
 }
Пример #7
0
        public static void CreateBees(int scoutCount)
        {
            scoutBees.Clear();

            int n = (int)(scoutCount * Constants.INITIAL_SEARCH_FRACTION);

            for (int i = 0; i < n; ++i)
            {
                Bee newBee = new Bee(Constants.DESTINATION_RADIUS, rand, Bee.State.EXPLORING);
                scoutBees.Add(newBee);
            }

            for (int i = 0; i < scoutCount * (1 - Constants.INITIAL_SEARCH_FRACTION); ++i)
            {
                scoutBees.Add(new Bee(Constants.DESTINATION_RADIUS, rand));
            }
        }
Пример #8
0
        /// <summary>
        /// Adds a new dancer's enthusiasum to the floor
        /// </summary>
        internal static void AddDancer(Bee b)
        {
            double quality = b.getSite().Quality;

            if (quality >= QualityThreshold)
            {
                if (!danceDistribution.ContainsKey(quality))
                {
                    danceDistribution.Add(quality, 1);
                }
                else
                {
                    ++danceDistribution[quality];
                }
                dancers.Add(b);
            }
        }
Пример #9
0
        public static void CreateBeesTest(int scoutCount, Site site)
        {
            scoutBees.Clear();

            Bee.State[] states = { Bee.State.EXPLORING, Bee.State.OBSERVING, Bee.State.RESTING, Bee.State.ASSESSING, Bee.State.DANCING };

            //            R   O   E   A   D
            int[] test = { 20, 20, 60, 0, 0 };

            for (int i = 0; i < test[0]; i++)
            {
                Bee newBee = new Bee(Constants.DESTINATION_RADIUS, rand, Bee.State.EXPLORING);
                scoutBees.Add(newBee);
            }
            for (int i = 0; i < test[1]; i++)
            {
                Bee newBee = new Bee(Constants.DESTINATION_RADIUS, rand, Bee.State.OBSERVING);
                scoutBees.Add(newBee);
            }
            for (int i = 0; i < test[2]; i++)
            {
                Bee newBee = new Bee(Constants.DESTINATION_RADIUS, rand, Bee.State.RESTING);
                scoutBees.Add(newBee);
            }
            for (int i = 0; i < test[3]; i++)
            {
                Bee newBee = new Bee(Constants.DESTINATION_RADIUS, rand, Bee.State.ASSESSING);
                newBee.FoundSite(site);
                scoutBees.Add(newBee);
            }
            for (int i = 0; i < test[4]; i++)
            {
                Bee newBee = new Bee(Constants.DESTINATION_RADIUS, rand, Bee.State.DANCING);
                newBee.setSite(site);
                scoutBees.Add(newBee);
            }
        }
Пример #10
0
        public static void changeState(Bee.State former, Bee.State current)
        {
            if (current == Bee.State.RETURNING)
            {
                if (former == Bee.State.ASSESSING)
                    decrementAssessers++;
                else
                    decrementExplorers++;
            }
            else if (former == Bee.State.RETURNING)
            {
                if (decrementExplorers > 0)
                {
                    --taskDistribution[Bee.State.EXPLORING];
                    decrementExplorers--;
                }
                else
                {
                    --taskDistribution[Bee.State.ASSESSING];
                    decrementAssessers--;
                }

                if (taskDistribution.ContainsKey(current) == false)
                {
                    taskDistribution.Add(current, 0);
                }
                ++taskDistribution[current];
            }
            else
            {
                if (current == Bee.State.FOLLOWING)
                    current = Bee.State.ASSESSING;
                
                if (former == Bee.State.FOLLOWING)
                    former = Bee.State.ASSESSING;

                if (former != Bee.State.ERROR)
                {
                    if (taskDistribution.ContainsKey(former) == false)
                    {
                        taskDistribution.Add(former, 0);
                    }
                    --taskDistribution[former];
                }

                if (taskDistribution.ContainsKey(current) == false)
                {
                    taskDistribution.Add(current, 0);
                }
                ++taskDistribution[current];
            }
        }
Пример #11
0
        /// <summary>
        /// Checks to see if the specified bee has discovered a potential nest site
        /// </summary>
        /// <param name="b">The bee we are currently checking</param>
        //private void CheckSearcher(Bee b) {
        //    foreach (Site s in potentialSites) {
        //        if (b.HasReachedDestination(s.Point)) {
        //            s.Visited = true;
        //            b.FoundSite(s);
        //        }
        //    }
        //}

        private void CheckSearcher(Bee b) {
            foreach (Site s in potentialSites) {
                if (!s.Visited && b.IsExploring()) {
                    if (b.HasReachedDestination(s.Point)) {
                        s.Visited = true;
                        b.FoundSite(s);
                    }
                }
            }
        }