// Use this for initialization
 void Start()
 {
     for (int i = 0; i < populationSize; i++)
     {
         GameObject   TempObject = Instantiate(Executer, new Vector3(0, 0, 0), Quaternion.identity);
         FoodSearcher GoodTest   = TempObject.AddComponent <FoodSearcher>();
         GoodTest.FoodSearcherSetup(GivenShape, GivenTarget, Cube);
         PopulationList.Add(GoodTest);
     }
 }
Esempio n. 2
0
        private async void FindNearestFoodPlaces()
        {
            ToggleProgressBar(true, "Looking for food places around");
            try
            {
                if (MyLocation != null)
                {
                    FoodSearcher Searcher   = new FoodSearcher();
                    var          FoodPlaces = await Searcher.SearchForFoodPlaces(MyLocation.Coordinate.Point, 500);

                    NearbyFoodPlaces = new ObservableCollection <FoodLocation>(FoodPlaces.results);
                }
            }
            catch (Exception ex)
            {
                MessageDialog Dialog = new MessageDialog("Nearby Food Places Search Failed");
                Dialog.ShowAsync();
            }

            ToggleProgressBar(false);
        }
    void SortList(List <FoodSearcher> unsortedList)
    {
        for (int i = 1; i < unsortedList.Count; i++)
        {
            for (int j = 1; j < i + 1; j++)
            {
                if (unsortedList [i - j].fitness > unsortedList [i - j + 1].fitness)
                {
                    FoodSearcher tempSecondTest = unsortedList [i - j + 1];
                    unsortedList [i - j + 1] = unsortedList [i - j];
                    unsortedList [i - j]     = tempSecondTest;
                }
                else
                {
                    break;
                }
            }
        }

        /*for (int i = 0; i < unsortedList.Count; i++){
         *      Debug.Log(unsortedList[i].fitness);
         * }*/
    }