public override Emotivector Update(History history, User user)
    {
        if (Emotivector == null)
        {
            return(null);
        }

        var state = PersistentDataStorage.Instance.GetState();
        // TODO HACK
        JSONArray values = state[Name].AsArray;

        if (_count < values.Count)
        {
            int i;
            for (i = _count; i < values.Count - 1; i++)
            {
                Emotivector.AddValue(MathUtils.Normalize(values[i], Min, Max));
                Emotivector.Predict();
            }

            // Don't predict the last addition
            Emotivector.AddValue(MathUtils.Normalize(values[i], Min, Max));
            _count = values.Count;

            return(Emotivector);
        }

        return(null);
    }
    public override Emotivector Update(History history, User user)
    {
        if (Emotivector == null)
        {
            return(null);
        }

        var values = GetListFromValues();

        if (_count < values.Count)
        {
            int i;
            for (i = _count; i < values.Count - 1; i++)
            {
                Emotivector.AddValue(MathUtils.Normalize(values[i], Min, Max));
                Emotivector.Predict();
            }

            // Don't predict the last addition
            Emotivector.AddValue(MathUtils.Normalize(values[i], Min, Max));
            _count = values.Count;

            return(Emotivector);
        }

        return(null);
    }
Esempio n. 3
0
    private void Start()
    {
        Emotivector emotivector;
//            IPredictor predictor = new MartinhoSimplePredictor();
//            IPredictor predictor = new MovingAveragePredictor();
//            IPredictor predictor = new WeightedMovingAveragePredictor();
//            IPredictor predictor = new ExponencialMovingAveragePredictor();
//            IPredictor predictor = new FirstDerivativeOnlyPredictor(new WeightedMovingAveragePredictor());
//            IPredictor predictor = new AdditiveFirstDerivativePredictor(new WeightedMovingAveragePredictor(),
//                new WeightedMovingAveragePredictor());
        IPredictor predictor = new AdditiveSecondDerivativePredictor(new WeightedMovingAveragePredictor(),
                                                                     new WeightedMovingAveragePredictor(), new WeightedMovingAveragePredictor());

        if (PopulateEmotivector)
        {
            emotivector = new Emotivector("Data", predictor, Values);
        }
        else
        {
            emotivector = new Emotivector("Data", predictor);
        }


        RunTutorPersonalityTest(emotivector);


        if (_viewDebugger)
        {
            _viewDebugger.SetEmotivector(emotivector);
        }
    }
Esempio n. 4
0
    private static void RunTutorPersonalityTest(Emotivector emotivector)
    {
        Tutor joao  = new Tutor("Joao");
        Tutor maria = new Tutor("Maria");

        joao.Personality = new ExpectancyPersonality(new Emotion[3, 6]
        {
            {
                /* Negative */
                new Emotion(EmotionEnum.Anger, .5f),
                new Emotion(EmotionEnum.Neutral, 1f),
                new Emotion(EmotionEnum.Surprise, .2f),
                new Emotion(EmotionEnum.Anger, .2f),
                new Emotion(EmotionEnum.Neutral, 1f),
                new Emotion(EmotionEnum.Surprise, .8f)
            },
            {
                /* Neutral */
                new Emotion(EmotionEnum.Sadness, .3f),
                new Emotion(EmotionEnum.Neutral, 1f),
                new Emotion(EmotionEnum.Happiness, .6f),
                new Emotion(EmotionEnum.Sadness, .2f),
                new Emotion(EmotionEnum.Neutral, 1f),
                new Emotion(EmotionEnum.Happiness, .8f)
            },
            {
                /* Positive */
                new Emotion(EmotionEnum.Sadness, .2f),
                new Emotion(EmotionEnum.Neutral, 1f),
                new Emotion(EmotionEnum.Happiness, .2f),
                new Emotion(EmotionEnum.Sadness, .2f),
                new Emotion(EmotionEnum.Neutral, 1f),
                new Emotion(EmotionEnum.Happiness, 1f)
            }
        });
        maria.Personality = joao.Personality;

        var emotivectorAppraisal = new EmotivectorAppraisal();
        var updater = new ValuesCheckAffectiveUpdater {
            Emotivector = emotivector
        };

        emotivectorAppraisal.AddUpdater(updater);
        IAffectiveAppraisal appraisal = emotivectorAppraisal;

        Debug.Log(joao.Emotion);
        emotivector.AddValue(.65f);
        appraisal.ComputeUserEmotion(null, null);
        appraisal.ComputeTutorEmotion(null, null, joao);
        Debug.Log(joao.Emotion);
        emotivector.AddValue(.4f);
        appraisal.ComputeUserEmotion(null, null);
        appraisal.ComputeTutorEmotion(null, null, joao);
        Debug.Log(joao.Emotion);
    }
 public void SetEmotivector(Emotivector emotivector)
 {
     _emotivector = emotivector;
     UpdateGraph();
 }