Esempio n. 1
0
        public void UpdateGoal()
        {
            //List3D<OCChunk> chunks = _map.GetChunks ();

            // Since this is probably bogging down the gameplay, switch it to block creation only.
            //FindGoalBlockPositionInChunks(chunks);

            Vector3 sourcePos   = gameObject.transform.position;
            Vector3 distanceVec = ((Vector3)GoalBlockPos) - sourcePos;

            float integrityChange = _goalNameToChangeRatePerSecond["Integrity"] / (distanceVec.magnitude * _distanceAttenuation);

            integrityChange = integrityChange / 10;

            UnityEngine.GameObject[] agiArray = UnityEngine.GameObject.FindGameObjectsWithTag("OCAGI");

            if (integrityChange > 0.04)
            {
                for (int iAGI = 0; iAGI < agiArray.Length; iAGI++)
                {
                    UnityEngine.GameObject agiObject = agiArray[iAGI];

                    OpenCog.Embodiment.OCPhysiologicalModel agiPhysModel = agiObject.GetComponent <OpenCog.Embodiment.OCPhysiologicalModel>();

                    OpenCog.Embodiment.OCPhysiologicalEffect nearHomeEffect = OCPhysiologicalEffect.CreateInstance <OCPhysiologicalEffect>();
                    nearHomeEffect.CostLevelProp = OpenCog.Embodiment.OCPhysiologicalEffect.CostLevel.NONE;

                    nearHomeEffect.FitnessChange = integrityChange;

                    //UnityEngine.Debug.Log ("Increasing Integrity by '" + integrityChange.ToString() + "'");

                    agiPhysModel.ProcessPhysiologicalEffect(nearHomeEffect);
                }
            }

            if (GoalBlockPos != Vector3i.zero && _map.GetBlock(GoalBlockPos).IsEmpty())
            {
                OpenCog.Utility.Console.Console console = OpenCog.Utility.Console.Console.Instance;
                console.AddConsoleEntry("I perceive no more " + _goalBlockType.GetName() + " blocks in my world.", "AGI Robot", OpenCog.Utility.Console.Console.ConsoleEntry.Type.SAY);
                System.Console.WriteLine(OCLogSymbol.RUNNING + "No more " + _goalBlockType.GetName() + " are reported");

                GoalBlockPos = Vector3i.zero;

                OCAction[] actions = gameObject.GetComponentsInChildren <OCAction>();

                foreach (OCAction action in actions)
                {
                    if (action.EndTarget != null)
                    {
                        action.EndTarget.transform.position = Vector3.zero;
                    }
                    if (action.StartTarget != null)
                    {
                        action.StartTarget.transform.position = Vector3.zero;
                    }
                }
            }
        }
Esempio n. 2
0
 /**
  * This method should be invoked to update the physiological model,
  * once an action has been done.
  * Currently, it would be invoked by ActionManager, by using
  *      SendMessage("processPhysiologicalEffect", phyEffect)
  */
 public void ProcessPhysiologicalEffect(OCPhysiologicalEffect effect)
 {
     effect.ApplyEffect(this);
     // Ensure energy is in acceptable bounds
     _energy = OpenCog.Utility.NumberUtil.zeroOneCut(_energy);
 }
		/**
	     * This method should be invoked to update the physiological model, 
	     * once an action has been done.
	     * Currently, it would be invoked by ActionManager, by using 
	     *      SendMessage("processPhysiologicalEffect", phyEffect)
	     */
		public void ProcessPhysiologicalEffect(OCPhysiologicalEffect effect)
		{
			effect.ApplyEffect(this);
			// Ensure energy is in acceptable bounds
			_energy = OpenCog.Utility.NumberUtil.zeroOneCut(_energy);

		}