Exemplo n.º 1
0
        public void Appraisal(KB kb, IBaseEvent evt, IWritableAppraisalFrame frame)
        {
            AppraisalRule activeRule = Evaluate(evt, kb, kb.Perspective);

            if (activeRule != null)
            {
                if (activeRule.Desirability != null)
                {
                    float des;
                    if (!float.TryParse(activeRule.Desirability.ToString(), out des))
                    {
                        throw new ArgumentException("Desirability can only be a float value");
                    }
                    frame.SetAppraisalVariable(OCCAppraisalVariables.DESIRABILITY, des);
                }

                if (activeRule.Praiseworthiness != null)
                {
                    float p;
                    if (!float.TryParse(activeRule.Praiseworthiness.ToString(), out p))
                    {
                        throw new ArgumentException("Desirability can only be a float value");
                    }
                    frame.SetAppraisalVariable(OCCAppraisalVariables.PRAISEWORTHINESS, p);
                }
            }
        }
Exemplo n.º 2
0
 public void OnEvent(IBaseEvent evt)
 {
     if (StateMap.ContainsKey(Current_State))
     {
         StateMap[Current_State].OnEvent(evt);
     }
 }
Exemplo n.º 3
0
        private void RemoveAllLinksTo(IBaseEvent theEvent, Object on)
        {
            FieldInfo[] fields = on.GetType().GetFields();

            for (int i = 0; i < fields.Length; i++)
            {
                if (fields[i].FieldType.IsSubclassOf(typeof(BaseMoment)))
                {
                    BaseMoment moment = fields[i].GetValue(on) as BaseMoment;
                    moment.RemoveIEvent(theEvent.AsObject());
                }
            }


            if (on is INodedEvent)
            {
                INodedEvent onDisplay = on as INodedEvent;

                BaseMoment[] additionalMoments;
                string[]     additionalNames;
                onDisplay.GetAdditionalMoments(out additionalMoments, out additionalNames);

                if (additionalMoments != null)
                {
                    for (int i = 0; i < additionalMoments.Length; i++)
                    {
                        additionalMoments[i].RemoveIEvent(theEvent.AsObject());
                    }
                }
            }
        }
Exemplo n.º 4
0
 public void Reset(IBaseEvent evt)
 {
     this.AppraisedEvent = evt;
     this.LastChange     = 0;
     this.nestedFrames.Clear();
     this.appraisalVariables.Clear();
 }
 public Task Handle(IBaseEvent message, IMessageHandlerContext context)
 {
     Data.DataId = message.DataId;
     MarkAsComplete();
     testContext.DidSagaComplete = true;
     return(Task.FromResult(0));
 }
Exemplo n.º 6
0
 public void RemoveAllLinksTo(IBaseEvent theEvent)
 {
     for (int i = 0; i < events.Count; i++)
     {
         RemoveAllLinksTo(theEvent, events[i]);
     }
 }
Exemplo n.º 7
0
        /*public const int GOALCONFIRMED = 1;
         * public const int GOALUNCONFIRMED = 0;
         * public const int GOALDISCONFIRMED = 2;
         */
        private static OCCBaseEmotion OCCAppraiseCompoundEmotions(IBaseEvent evt, float desirability, float praiseworthiness)
        {
            if ((desirability == 0) || (praiseworthiness == 0) || ((desirability > 0) != (praiseworthiness > 0)))
            {
                return(null);
            }

            float potential = Math.Abs(desirability + praiseworthiness) * 0.5f;

            Name           direction;
            OCCEmotionType emoType;

            if (evt.Subject == Name.SELF_SYMBOL)
            {
                direction = Name.SELF_SYMBOL;
                emoType   = (desirability > 0) ? OCCEmotionType.Gratification : OCCEmotionType.Remorse;
            }
            else
            {
                direction = evt.Subject ?? Name.UNIVERSAL_SYMBOL;
                emoType   = (desirability > 0) ? OCCEmotionType.Gratitude : OCCEmotionType.Anger;
            }

            return(new OCCBaseEmotion(emoType, potential, evt.Id, direction, evt.EventName));
        }
 public void Reset(IBaseEvent evt)
 {
     this.AppraisedEvent = evt;
     this.LastChange = 0;
     this.nestedFrames.Clear();
     this.appraisalVariables.Clear();
 }
Exemplo n.º 9
0
        private static OCCBaseEmotion OCCAppraiseAttribution(IBaseEvent evt, float like)
        {
            const float    magicFactor = 0.7f;
            OCCEmotionType emoType     = (like >= 0)?OCCEmotionType.Love:OCCEmotionType.Hate;

            return(new OCCBaseEmotion(emoType, Math.Abs(like) * magicFactor, evt.Id, evt.Subject == null?Name.UNIVERSAL_SYMBOL:evt.Subject, evt.EventName));
        }
Exemplo n.º 10
0
        public void Appraisal(EmotionalAppraisalAsset emotionalModule, IBaseEvent evt, IWritableAppraisalFrame frame)
        {
            AppraisalRule selfEvaluation = Evaluate(evt, emotionalModule.Kb);

            if (selfEvaluation != null)
            {
                if (selfEvaluation.Desirability != 0)
                {
                    frame.SetAppraisalVariable(OCCAppraisalVariables.DESIRABILITY, selfEvaluation.Desirability);
                }

                //if (selfEvaluation.DesirabilityForOther != 0)
                //{
                //	string other;
                //	if (selfEvaluation.Other != null)
                //		other = selfEvaluation.Other.ToString();
                //	else if (evt.Target != null)
                //		other = evt.Target;
                //	else
                //		other = evt.Subject;

                //	frame.SetAppraisalVariable(OCCAppraisalVariables.DESIRABILITY_FOR_OTHER + other, selfEvaluation.DesirabilityForOther);
                //}

                if (selfEvaluation.Praiseworthiness != 0)
                {
                    frame.SetAppraisalVariable(OCCAppraisalVariables.PRAISEWORTHINESS, selfEvaluation.Praiseworthiness);
                }

                //if (selfEvaluation.Like != 0)
                //	frame.SetAppraisalVariable(OCCAppraisalVariables.LIKE, selfEvaluation.Like);
            }
        }
Exemplo n.º 11
0
 /// <summary>
 /// 대상에게 이벤트 전송
 /// </summary>
 /// <param name="to">대상 이벤트 핸들러</param>
 /// <param name="evt">전송할 이벤트</param>
 public void Send(IEventHandler to, IBaseEvent evt)
 {
     if (to.IsEnabled)
     {
         to.OnEvent(evt);
     }
 }
Exemplo n.º 12
0
 public bool Dispatch(IBaseEvent param)
 {
     if (null == mBindGo)
     {
         return(false);
     }
     mCallback.Invoke(param);
     return(true);
 }
Exemplo n.º 13
0
 /// <summary>
 /// 모든 이벤트 핸들러에 전송
 /// </summary>
 /// <param name="evt">전송할 이벤트</param>
 public void Broadcast(IBaseEvent evt)
 {
     foreach (IEventHandler handler in handlerList)
     {
         if (handler.IsEnabled)
         {
             handler.OnEvent(evt);
         }
     }
 }
Exemplo n.º 14
0
 /// <summary>
 /// 주어진 이름의 채널에 이벤트를 전송한다.
 /// </summary>
 /// <param name="channelName">대상 채널 이름</param>
 /// <param name="evt">전송할 이벤트</param>
 public void Send(string channelName, IBaseEvent evt)
 {
     channelList.ForEach((channel) =>
     {
         if (channel.Name == channelName)
         {
             Send(channel, evt);
         }
     }
                         );
 }
Exemplo n.º 15
0
        public AppraisalRule Evaluate(IBaseEvent evt, IQueryable kb, Name perspective)
        {
            var auxEvt = evt.EventName.SwapTerms(perspective, Name.SELF_SYMBOL);

            foreach (var possibleAppraisals in this.Rules.Unify(auxEvt))
            {
                //This next for loop is to prevent a problem with using appraisal rules that contain SELF
                //This will replace all the subs with SELF with the name of the perspective
                foreach (var sub in possibleAppraisals.Item2)
                {
                    if (sub.SubValue.Value == Name.SELF_SYMBOL)
                    {
                        sub.SubValue = new ComplexValue(perspective);
                    }
                }
                var substitutions = new[] { possibleAppraisals.Item2 };                 //this adds the subs found in the eventName
                foreach (var appRule in possibleAppraisals.Item1)
                {
                    var finalSubsList = appRule.Conditions.Unify(kb, Name.SELF_SYMBOL, substitutions);

                    //The appraisal will only consider the substitution set that it has the most certainty in
                    var mostCertainSubSet = this.DetermineSubstitutionSetWithMostCertainty(finalSubsList);
                    if (mostCertainSubSet != null)
                    {
                        foreach (var appVariable in appRule.getAppraisalVariables())
                        {
                            appVariable.Value = appVariable.Value.MakeGround(mostCertainSubSet);

                            var minCertainty = mostCertainSubSet.FindMinimumCertainty();

                            if (appVariable.Target != null && appVariable.Target != (Name)"-")
                            {
                                appVariable.Target = appVariable.Target.MakeGround(mostCertainSubSet);
                            }

                            float f;

                            if (float.TryParse(appVariable.Value.ToString(), out f))
                            {
                                var aux = float.Parse(appVariable.Value.ToString()) * minCertainty;
                                appVariable.Value = Name.BuildName(aux);
                            }
                            else
                            {
                                continue;
                            }
                        }

                        return(appRule);
                    }
                }
            }
            return(null);
        }
Exemplo n.º 16
0
        public virtual void Update(double lastTick)
        {
            foreach (Packet packet in incomingPackets.DequeueMultiple(MaxIncomingPacketsPerUpdate))
            {
                foreach (SubPacket subPacket in packet.SubPackets)
                {
                    if (!CanProcessSubPacket(subPacket))
                    {
                        continue;
                    }

                    try
                    {
                        PacketManager.InvokeHandler(this, subPacket);
                    }
                    catch (Exception exception)
                    {
                        Console.WriteLine(exception);
                    }
                }
            }

            while (events.Count > 0)
            {
                IBaseEvent nextEvent = events.Peek();
                if (!nextEvent.CanExecute())
                {
                    break;
                }

                events.Dequeue();
                nextEvent.Execute();
            }

            (ConnectionHeartbeatResult result, uint pulseTime) = Heartbeat.Update(lastTick);
            switch (result)
            {
            case ConnectionHeartbeatResult.Pulse:
            {
                Send(0u, 0u, new KeepAliveRequest
                    {
                        Check     = (uint)Guid.NewGuid().GetHashCode(),
                        Timestamp = pulseTime
                    });
                break;
            }

            case ConnectionHeartbeatResult.Flatline:
                Disconnect();
                break;
            }

            FlushPacketQueue();
        }
Exemplo n.º 17
0
    /// <summary>
    /// 해당 채널에 이벤트를 전송한다.
    /// </summary>
    /// <param name="to">대상 채널</param>
    /// <param name="evt">전송할 이벤트</param>
    public void Send(EventChannel to, IBaseEvent evt)
    {
        if (DebugMode)
        {
            Debug.Log("EventService.Send : " + evt);
        }

        if (null != to && to.isSendable)
        {
            to.Broadcast(evt);
        }
    }
Exemplo n.º 18
0
        private static OCCBaseEmotion AppraiseGoalSuccessProbability(IBaseEvent evt, float goalProbability, float previousProbabilityValue, float significance)
        {
            //Significante is too low
            var potential = significance;

            if (previousProbabilityValue == goalProbability)
            {
                return(new OCCBaseEmotion(OCCEmotionType.Hope, 0, evt.Id, evt.EventName));
            }


            if (goalProbability > previousProbabilityValue)
            {
                if (goalProbability == 1)
                {
                    if (previousProbabilityValue <= 0.5)
                    {
                        return(new OCCBaseEmotion(OCCEmotionType.Relief, Math.Abs(goalProbability) * potential, evt.Id, evt.EventName));
                    }

                    else
                    {
                        return(new OCCBaseEmotion(OCCEmotionType.Satisfaction, Math.Abs(goalProbability) * potential, evt.Id, evt.EventName));
                    }
                }
                else
                {
                    return(new OCCBaseEmotion(OCCEmotionType.Hope, Math.Abs(goalProbability) * potential, evt.Id, evt.EventName));
                }
            }

            else  //if(goalProbability < goal.Likelihood)
            {
                if (goalProbability == 0)
                {
                    if (previousProbabilityValue >= 0.5)
                    {
                        return(new OCCBaseEmotion(OCCEmotionType.Disappointment, (1 - goalProbability) * potential, evt.Id, evt.EventName));
                    }

                    else
                    {
                        return(new OCCBaseEmotion(OCCEmotionType.FearsConfirmed, (1 - goalProbability) * potential, evt.Id, evt.EventName));
                    }
                }

                else
                {
                    return(new OCCBaseEmotion(OCCEmotionType.Fear, (1 - goalProbability) * potential, evt.Id, evt.EventName));
                }
            }
        }
Exemplo n.º 19
0
        public void OnEventReceived(IBaseEvent baseEvent, EventType eventType)
        {
            switch (eventType)
            {
            case EventType.FloorSelected:
                //do nothing
                break;

            case EventType.FloorReached:
                onfloorReached(baseEvent.PayLoad);
                break;
            }
        }
Exemplo n.º 20
0
 public AppraisalRule Evaluate(IBaseEvent evt, KB kb)
 {
     foreach (var possibleAppraisals in Rules.Unify(evt.EventName.ApplyPerspective(kb.Perspective)))
     {
         var conditions = new[] { possibleAppraisals.Item2 };
         foreach (var appraisal in possibleAppraisals.Item1)
         {
             if (appraisal.Conditions.Evaluate(kb, Name.SELF_SYMBOL, conditions))
             {
                 return(appraisal);
             }
         }
     }
     return(null);
 }
Exemplo n.º 21
0
        public IEnumerable <AppraisalRule> Evaluate(IBaseEvent evt, IQueryable kb, Name perspective)
        {
            // Switching the SELF term for the correct name withint the event

            var auxEvt = evt.EventName.SwapTerms(perspective, Name.SELF_SYMBOL);
            var result = new List <AppraisalRule>();

            foreach (var r in this.Rules)
            {
                // Trying to find all possible initial substitutions;
                var initialSubSet = Unifier.Unify(r.EventName, auxEvt);


                if (initialSubSet == null)
                {
                    initialSubSet = new SubstitutionSet();
                }


                if (auxEvt.Match(r.EventName) || initialSubSet.Any())
                {
                    var finalSubSet = r.Conditions.Unify(kb, perspective, new List <SubstitutionSet>()
                    {
                        new SubstitutionSet(initialSubSet)
                    });
                    if (finalSubSet != null)
                    {
                        //TODO: Handle uncertainty in beliefs
                        foreach (var set in finalSubSet)
                        {
                            var a = new AppraisalRule(r);
                            a.EventName.MakeGround(set);
                            foreach (var variable in a.getAppraisalVariables())
                            {
                                variable.Value = variable.Value.MakeGround(set);
                                if (variable.Target != null && variable.Target != (Name)"-")
                                {
                                    variable.Target = variable.Target.MakeGround(set);
                                }
                            }
                            result.Add(a);
                        }
                    }
                }
            }
            return(result);
        }
Exemplo n.º 22
0
        private static OCCBaseEmotion OCCAppraiseFortuneOfOthers(IBaseEvent evt, float desirability, float desirabilityForOther, string target)
        {
            float potential = (Math.Abs(desirabilityForOther) + Math.Abs(desirability)) * 0.5f;

            OCCEmotionType emoType;

            if (desirability >= 0)
            {
                emoType = (desirabilityForOther >= 0) ? OCCEmotionType.HappyFor : OCCEmotionType.Gloating;
            }
            else
            {
                emoType = (desirabilityForOther >= 0) ? OCCEmotionType.Resentment : OCCEmotionType.Pitty;
            }

            return(new OCCBaseEmotion(emoType, potential, evt.Id, (Name)target, evt.EventName));
        }
Exemplo n.º 23
0
        public AppraisalRule Evaluate(IBaseEvent evt, IQueryable kb, Name perspective)
        {
            var auxEvt = evt.EventName.SwapTerms(perspective, Name.SELF_SYMBOL);

            foreach (var possibleAppraisals in this.Rules.Unify(auxEvt))
            {
                //This next for loop is to prevent a problem with using appraisal rules that contain SELF
                //This will replace all the subs with SELF with the name of the perspective
                foreach (var sub in possibleAppraisals.Item2)
                {
                    if (sub.SubValue.Value == Name.SELF_SYMBOL)
                    {
                        sub.SubValue = new ComplexValue(perspective);
                    }
                }
                var substitutions = new[] { possibleAppraisals.Item2 };                 //this adds the subs found in the eventName
                foreach (var appRule in possibleAppraisals.Item1)
                {
                    var finalSubsList = appRule.Conditions.Unify(kb, Name.SELF_SYMBOL, substitutions);

                    //The appraisal will only consider the substitution set that it has the most certainty in
                    var mostCertainSubSet = this.DetermineSubstitutionSetWithMostCertainty(finalSubsList);
                    if (mostCertainSubSet != null)
                    {
                        appRule.Desirability     = appRule.Desirability.MakeGround(mostCertainSubSet);
                        appRule.Praiseworthiness = appRule.Praiseworthiness.MakeGround(mostCertainSubSet);
                        if (!appRule.Desirability.IsGrounded || !appRule.Praiseworthiness.IsGrounded)
                        {
                            return(null);
                        }

                        //Modify the appraisal variables based on the certainty of the substitutions
                        var minCertainty = mostCertainSubSet.FindMinimumCertainty();

                        var aux = float.Parse(appRule.Desirability.ToString()) * minCertainty;
                        appRule.Desirability = Name.BuildName(aux);

                        aux = float.Parse(appRule.Praiseworthiness.ToString()) * minCertainty;
                        appRule.Praiseworthiness = Name.BuildName(aux);

                        return(appRule);
                    }
                }
            }
            return(null);
        }
Exemplo n.º 24
0
        //private static OCCBaseEmotion OCCAppraiseFortuneOfOthers(uint evtId, float desirability, float desirabilityForOther, string target)
        //{
        //	float potential = (Math.Abs(desirabilityForOther) + Math.Abs(desirability)) * 0.5f;

        //	OCCEmotionType emoType;
        //	if (desirability >= 0)
        //		emoType = (desirabilityForOther >= 0) ? OCCEmotionType.HappyFor : OCCEmotionType.Gloating;
        //	else
        //		emoType = (desirabilityForOther >= 0) ? OCCEmotionType.Resentment : OCCEmotionType.Pitty;

        //	return new OCCBaseEmotion(emoType, potential, evtId, string.IsNullOrEmpty(target) ? Name.UNIVERSAL_SYMBOL : Name.BuildName(target));
        //}

        private static OCCBaseEmotion OCCAppraisePraiseworthiness(IBaseEvent evt, float praiseworthiness, Name perspective)
        {
            Name           direction;
            OCCEmotionType emoType;

            if (evt.Subject == perspective)
            {
                direction = perspective;
                emoType   = (praiseworthiness >= 0) ? OCCEmotionType.Pride : OCCEmotionType.Shame;
            }
            else
            {
                direction = evt.Subject;
                emoType   = (praiseworthiness >= 0) ? OCCEmotionType.Admiration : OCCEmotionType.Reproach;
            }

            return(new OCCBaseEmotion(emoType, Math.Abs(praiseworthiness), evt.Id, direction, evt.EventName));
        }
Exemplo n.º 25
0
        private static OCCBaseEmotion OCCAppraisePraiseworthiness(IBaseEvent evt, float praiseworthiness, string target)
        {
            Name           direction;
            OCCEmotionType emoType;

            if (target == "SELF" || target == evt.Subject.ToString())
            {
                direction = Name.SELF_SYMBOL;
                emoType   = (praiseworthiness >= 0) ? OCCEmotionType.Pride : OCCEmotionType.Shame;
            }
            else
            {
                direction = (Name)target;
                emoType   = (praiseworthiness >= 0) ? OCCEmotionType.Admiration : OCCEmotionType.Reproach;
            }

            return(new OCCBaseEmotion(emoType, Math.Abs(praiseworthiness), evt.Id, direction, evt.EventName));
        }
        //private static OCCBaseEmotion OCCAppraiseFortuneOfOthers(uint evtId, float desirability, float desirabilityForOther, string target)
        //{
        //	float potential = (Math.Abs(desirabilityForOther) + Math.Abs(desirability)) * 0.5f;

        //	OCCEmotionType emoType;
        //	if (desirability >= 0)
        //		emoType = (desirabilityForOther >= 0) ? OCCEmotionType.HappyFor : OCCEmotionType.Gloating;
        //	else
        //		emoType = (desirabilityForOther >= 0) ? OCCEmotionType.Resentment : OCCEmotionType.Pitty;

        //	return new OCCBaseEmotion(emoType, potential, evtId, string.IsNullOrEmpty(target) ? Name.UNIVERSAL_SYMBOL : Name.BuildName(target));
        //}

        private static OCCBaseEmotion OCCAppraisePraiseworthiness(IBaseEvent evt, float praiseworthiness)
        {
            Name           direction;
            OCCEmotionType emoType;

            if (evt.Subject == Name.SELF_SYMBOL)
            {
                direction = Name.SELF_SYMBOL;
                emoType   = (praiseworthiness >= 0) ? OCCEmotionType.Pride : OCCEmotionType.Shame;
            }
            else
            {
                direction = evt.Subject ?? Name.UNIVERSAL_SYMBOL;
                emoType   = (praiseworthiness >= 0) ? OCCEmotionType.Admiration : OCCEmotionType.Reproach;
            }

            return(new OCCBaseEmotion(emoType, Math.Abs(praiseworthiness), evt.Id, direction));
        }
Exemplo n.º 27
0
    /// <summary>
    /// 모든 채널에 이벤트를 전송한다.
    /// </summary>
    /// <param name="evt">전송할 이벤트</param>
    public void Broadcast(IBaseEvent evt)
    {
        if (DebugMode)
        {
            Debug.Log("EventService.Broadcast : " + evt);
        }

        foreach (EventChannel channel in channelList)
        {
            // 함수 호출 오버로드
            //Send(channel, evt);

            if (null != channel && channel.isSendable)
            {
                channel.Broadcast(evt);
            }
        }
    }
Exemplo n.º 28
0
        void OnFullScreenEvent(IntPtr pParametr, IBaseEvent pEvent)
        {
            IEvGoFullScreen p_event = (IEvGoFullScreen)pEvent;

            uint res_width, res_height;
            bool go_fscreen;

            p_event.GetResolution(out res_width, out res_height, out go_fscreen);

            if (go_fscreen)
            {
                prevWindowWidth  = res_width;
                prevWindowHeight = res_height;

                pEngineCore.GetDesktopResolution(out res_width, out res_height);
                p_event.SetResolution(res_width, res_height);
            }
            else
            {
                p_event.SetResolution(prevWindowWidth, prevWindowHeight);
            }
        }
Exemplo n.º 29
0
        public void Appraisal(KB kb, IBaseEvent evt, IWritableAppraisalFrame frame)
        {
            AppraisalRule activeRule = Evaluate(evt, kb, kb.Perspective);

            if (activeRule != null)
            {
                foreach (var appVar in activeRule.getAppraisalVariables())
                {
                    float des;
                    if (!float.TryParse(appVar.Value.ToString(), out des))
                    {
                        throw new ArgumentException(appVar.Name + " can only be a float value");
                    }


                    if (appVar.Name == OCCAppraisalVariables.GOALSUCCESSPROBABILITY)
                    {
                        frame.SetAppraisalVariable(OCCAppraisalVariables.GOALSUCCESSPROBABILITY + " " + appVar.Target, des);
                    }

                    else if (appVar.Name == OCCAppraisalVariables.PRAISEWORTHINESS)
                    {
                        frame.SetAppraisalVariable(OCCAppraisalVariables.PRAISEWORTHINESS + " " + appVar.Target, des);
                    }

                    else
                    {
                        frame.SetAppraisalVariable(appVar.Name, des);
                    }

                    if (appVar.Target != null && appVar.Target != (Name)"-" && appVar.Target != (Name)"SELF")
                    {
                        frame.SetAppraisalVariable(OCCAppraisalVariables.DESIRABILITY_FOR_OTHER + "" + appVar.Target, des);
                    }
                }
            }
        }
Exemplo n.º 30
0
        public void Appraisal(KB kb, IBaseEvent evt, IAppraisalFrame frame)
        {
            IEnumerable <AppraisalRule> activeRules = Evaluate(evt, kb, kb.Perspective);

            foreach (var rule in activeRules)
            {
                foreach (var appVar in rule.getAppraisalVariables())
                {
                    float des;
                    if (!float.TryParse(appVar.Value.ToString(), NumberStyles.Any, CultureInfo.InvariantCulture, out des))
                    {
                        throw new ArgumentException(appVar.Name + " can only be a float value");
                    }

                    else if (appVar.Name == OCCAppraisalVariables.DESIRABILITY_FOR_OTHER)
                    {
                        frame.SetAppraisalVariable(OCCAppraisalVariables.DESIRABILITY_FOR_OTHER + " " + appVar.Target, des);
                    }

                    else if (appVar.Name == OCCAppraisalVariables.GOALSUCCESSPROBABILITY)
                    {
                        frame.SetAppraisalVariable(OCCAppraisalVariables.GOALSUCCESSPROBABILITY + " " + appVar.Target, des);
                    }

                    else if (appVar.Name == OCCAppraisalVariables.PRAISEWORTHINESS)
                    {
                        frame.SetAppraisalVariable(OCCAppraisalVariables.PRAISEWORTHINESS + " " + appVar.Target, des);
                    }

                    else
                    {
                        frame.SetAppraisalVariable(appVar.Name, des);
                    }
                }
            }
        }
 public AppraisalRule Evaluate(IBaseEvent evt, IQueryable kb, Name perspective)
 {
     foreach (var possibleAppraisals in Rules.Unify(evt.EventName.ApplyPerspective(perspective)))
     {
         var conditions = new[] {possibleAppraisals.Item2};
         foreach (var appraisal in possibleAppraisals.Item1)
         {
             if (appraisal.Conditions.Evaluate(kb,Name.SELF_SYMBOL, conditions))
                 return appraisal;
         }
     }
     return null;
 }
Exemplo n.º 32
0
 virtual public void OnEvent(IBaseEvent evt)
 {
 }
        private static OCCBaseEmotion OCCAppraiseCompoundEmotions(IBaseEvent evt, float desirability, float praiseworthiness)
        {
            if ((desirability == 0) || (praiseworthiness == 0) || ((desirability > 0) != (praiseworthiness > 0)))
                return null;

            float potential = Math.Abs(desirability + praiseworthiness) * 0.5f;

            Name direction;
            OCCEmotionType emoType;

            if(evt.Subject == Name.SELF_SYMBOL)
            {
                direction = Name.SELF_SYMBOL;
                emoType = (desirability > 0) ? OCCEmotionType.Gratification : OCCEmotionType.Remorse;
            }
            else
            {
                direction = evt.Subject ?? Name.UNIVERSAL_SYMBOL;
                emoType = (desirability > 0) ? OCCEmotionType.Gratitude : OCCEmotionType.Anger;
            }

            return new OCCBaseEmotion(emoType, potential, evt.Id, direction);
        }
Exemplo n.º 34
0
        void OnFullScreenEvent(IntPtr pParametr, IBaseEvent pEvent)
        {
            IEvGoFullScreen p_event = (IEvGoFullScreen)pEvent;

            uint res_width, res_height;
            bool go_fscreen;
            p_event.GetResolution(out res_width, out  res_height, out go_fscreen);

            if (go_fscreen)
            {
                prevWindowWidth = res_width;
                prevWindowHeight = res_height;

                pEngineCore.GetDesktopResolution(out  res_width, out res_height);
                p_event.SetResolution(res_width, res_height);
            }
            else
                p_event.SetResolution(prevWindowWidth, prevWindowHeight);
        }
        //private static OCCBaseEmotion OCCAppraiseFortuneOfOthers(uint evtId, float desirability, float desirabilityForOther, string target)
        //{
        //    float potential = (Math.Abs(desirabilityForOther) + Math.Abs(desirability)) * 0.5f;
        //    OCCEmotionType emoType;
        //    if (desirability >= 0)
        //        emoType = (desirabilityForOther >= 0) ? OCCEmotionType.HappyFor : OCCEmotionType.Gloating;
        //    else
        //        emoType = (desirabilityForOther >= 0) ? OCCEmotionType.Resentment : OCCEmotionType.Pitty;
        //    return new OCCBaseEmotion(emoType, potential, evtId, string.IsNullOrEmpty(target) ? Name.UNIVERSAL_SYMBOL : Name.BuildName(target));
        //}
        private static OCCBaseEmotion OCCAppraisePraiseworthiness(IBaseEvent evt, float praiseworthiness)
        {
            Name direction;
            OCCEmotionType emoType;

            if (evt.Subject == Name.SELF_SYMBOL)
            {
                direction = Name.SELF_SYMBOL;
                emoType = (praiseworthiness >= 0) ? OCCEmotionType.Pride : OCCEmotionType.Shame;
            }
            else
            {
                direction = evt.Subject ?? Name.UNIVERSAL_SYMBOL;
                emoType = (praiseworthiness >= 0) ? OCCEmotionType.Admiration : OCCEmotionType.Reproach;
            }

            return new OCCBaseEmotion(emoType, Math.Abs(praiseworthiness), evt.Id, direction);
        }
        public void Appraisal(EmotionalAppraisalAsset emotionalModule, IBaseEvent evt, IWritableAppraisalFrame frame)
        {
            AppraisalRule selfEvaluation = Evaluate(evt, emotionalModule,emotionalModule.Perspective);
            if (selfEvaluation != null)
            {
                if (selfEvaluation.Desirability != 0)
                    frame.SetAppraisalVariable(OCCAppraisalVariables.DESIRABILITY, selfEvaluation.Desirability);

                //if (selfEvaluation.DesirabilityForOther != 0)
                //{
                //	string other;
                //	if (selfEvaluation.Other != null)
                //		other = selfEvaluation.Other.ToString();
                //	else if (evt.Target != null)
                //		other = evt.Target;
                //	else
                //		other = evt.Subject;

                //	frame.SetAppraisalVariable(OCCAppraisalVariables.DESIRABILITY_FOR_OTHER + other, selfEvaluation.DesirabilityForOther);
                //}

                if (selfEvaluation.Praiseworthiness != 0)
                    frame.SetAppraisalVariable(OCCAppraisalVariables.PRAISEWORTHINESS, selfEvaluation.Praiseworthiness);

                //if (selfEvaluation.Like != 0)
                //	frame.SetAppraisalVariable(OCCAppraisalVariables.LIKE, selfEvaluation.Like);
            }
        }