Exemplo 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;
                    }
                }
            }
        }
Exemplo n.º 2
0
        public void ApplyEffect(OCPhysiologicalModel model)
        {
            // Update energy
            model.Energy -= GetActionCost((float)model.Fitness);
            model.Energy += _energyIncrease;

            model.Fitness += _fitnessChange;

            model.Fitness = OpenCog.Utility.NumberUtil.zeroOneCut(model.Fitness);
            model.Energy  = OpenCog.Utility.NumberUtil.zeroOneCut(model.Energy);

            // Set new mode
            model.CurrentMode = _newAvatarMode;
            // Change factors...
            foreach (string factorName in _changeFactors.Keys)
            {
                float changeValue = _changeFactors[factorName];
                if (changeValue < 0.0f)
                {
                    model.BasicFactorMap[factorName].Decrease(-changeValue);
                }
                else
                {
                    model.BasicFactorMap[factorName].Increase(changeValue);
                }
            }
            // Reset factors
            foreach (string factorName in _resetFactors)
            {
                model.BasicFactorMap[factorName].Reset();
            }

            // Deal with the action which has effects on the physiological factors.

            // For reference, these are the old physiological effect of actions.

            /*switch (effect.actionName)
             * {
             * case "sleep":
             * this.currentMode = AvatarMode.SLEEP;
             * break;
             * case "eat":
             * // increase the energy
             * this.energy += EAT_ENERGY_INCREASE;
             * // decrease the hunger
             * basicFactorMap["hunger"].decrease(this.energy);
             * // increase the poo urgency
             * basicFactorMap["poo_urgency"].increase(EAT_POO_INCREASE);
             * break;
             * case "drink":
             * // decrease the thirst
             * basicFactorMap["thirst"].decrease(DRINK_THIRST_DECREASE);
             * // increase the pee urgency
             * basicFactorMap["pee_urgency"].increase(DRINK_PEE_INCREASE);
             * break;
             * case "pee":
             * // reset the pee urgency
             * basicFactorMap["pee_urgency"].reset();
             * break;
             * case "poo":
             * // reset the poo urgency
             * basicFactorMap["poo_urgency"].reset();
             * break;
             * default:
             * break;
             * }*/
        }
	public void ApplyEffect(OCPhysiologicalModel model)
	{
		// Update energy
		model.Energy -= getActionCost((float)model.Fitness);
		model.Energy += _energyIncrease;
        
		model.Fitness += _fitnessChange;
			
		model.Fitness = OpenCog.Utility.NumberUtil.zeroOneCut(model.Fitness);
		model.Energy = OpenCog.Utility.NumberUtil.zeroOneCut(model.Energy);
        
		// Set new mode
		model.CurrentMode = _newAvatarMode;
		// Change factors...
		foreach(string factorName in _changeFactors.Keys)
		{
			float changeValue = _changeFactors[factorName];
			if(changeValue < 0.0f)
			{
				model.BasicFactorMap[factorName].Decrease(-changeValue);
			}
			else
			{
				model.BasicFactorMap[factorName].Increase(changeValue);
			}
		}
		// Reset factors
		foreach(string factorName in _resetFactors)
		{
			model.BasicFactorMap[factorName].Reset();
		}

		// Deal with the action which has effects on the physiological factors.
        
		// For reference, these are the old physiological effect of actions.
		/*switch (effect.actionName)
        {
            case "sleep":
                this.currentMode = AvatarMode.SLEEP;
                break;
            case "eat":
                // increase the energy
                this.energy += EAT_ENERGY_INCREASE;
                // decrease the hunger
                basicFactorMap["hunger"].decrease(this.energy);
                // increase the poo urgency
                basicFactorMap["poo_urgency"].increase(EAT_POO_INCREASE);
                break;
            case "drink":
                // decrease the thirst
                basicFactorMap["thirst"].decrease(DRINK_THIRST_DECREASE);
                // increase the pee urgency
                basicFactorMap["pee_urgency"].increase(DRINK_PEE_INCREASE);
                break;
            case "pee":
                // reset the pee urgency
                basicFactorMap["pee_urgency"].reset();
                break;
            case "poo":
                // reset the poo urgency
                basicFactorMap["poo_urgency"].reset();
                break;
            default:
                break;
        }*/
        
        
	}