// Update food info
        public void UpdateFoodInfo(FoodInfo info)
        {
            int index = -1;

            for (int i = 0; i < openlist.Count; i++)
            {
                if (openlist[i].ID == info.ID)
                {
                    index = i;
                }
            }

            // if the food already in the openlist, check version of info
            if (index != -1)
            {
                if (info.currentAmount == 0)
                {
                    openlist.RemoveAt(index);
                    closelist.Add(info);
                }
                else
                {
                    if (openlist [index].version < info.version)
                    {
                        openlist [index] = info;
                    }
                }
            }
            // if the food is new
            else
            {
                if (info.currentAmount == 0)
                {
                    if (!closelist.Contains(info))
                    {
                        closelist.Add(info);
                    }
                }
                else
                {
                    openlist.Add(info);
                }
            }
        }
        void Update()
        {
            int currentCapacity = foragerMemory.info.currentCapacity;

            if (currentCapacity != 30)
            {
                if (ForagerMemory.openlist.Count == 0)
                {
                    foragerExplore.Explore();
                }
                else
                {
                    FoodInfo info = foragerMemory.PickBestFood();
                    foragerMovement.GoTo(info.position);
                    foragerMemory.currentAction = "Go to food";
                }
            }
            else
            {
                foragerMovement.GoTo(foragerMemory.hivePos);
                foragerMemory.currentAction = "Go home";
            }
        }
 // Calculate score of food source, Score is 0.8*distance+0.2*currentCapacity, the larger the worse
 float FoodScore(FoodInfo food)
 {
     return(Vector3.Distance(food.position, gameObject.transform.position));
 }
 void Awake()
 {
     // Set the initial amount of the food.
     info = new FoodInfo(gameObject);
     anmi = GetComponent <Animator> ();
 }