void Update () {
			int currentCapacity = foragerMemory.info.currentCapacity;
			GameObject target = foragerMemory.foragerCommunicated;

			if (target == null) {
				if (timer > 1f) {
					foragerCommunicate.EstablishCommunication ();
					timer = 0f;
				}
			} else {
				foragerMovement.GoTo (target.transform.position);
				foragerMemory.currentAction = "Communicate";
				return;
			}

			timer += Time.deltaTime;

			if (currentCapacity != 30) {
				if (foragerMemory.openlist.Count == 0) {
					foragerExplore.Explore ();
					foragerMemory.currentAction = "Explore";
				} else {
					FoodInfo info = foragerMemory.PickBestFood ();
					foragerMovement.GoTo (info.position);
					foragerMemory.currentAction = "Go to food";
				}
			} else {
				foragerMovement.GoTo (foragerMemory.hivePos);
				foragerMemory.currentAction = "Go home";
			}
		}
        // 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) * 0.8f + (100 - food.currentAmount) * 0.2f / 100);
 }
 void Awake()
 {
     // Set the initial amount of the food.
     info = new FoodInfo(gameObject);
     anmi = GetComponent <Animator> ();
 }