Example #1
0
    private float Weight(List <int> actionIds)
    {
        var tempAccumulatedValues = new GenericVector(_npc.AccumulatedValues.Size);

        tempAccumulatedValues.Sum(_npc.AccumulatedValues);

        for (var i = 0; i < actionIds.Count; i++)
        {
            var action = Actions[actionIds[i]];
            tempAccumulatedValues.Sum(action.PersonalityModifiers.ToGenericVector());
        }

        var angle  = GenericVector.GetAngle(tempAccumulatedValues, _npc.PersonalityValuesGenericVector);
        var weigth = 10 / (angle + 1);

        return(weigth);
    }
Example #2
0
        public void TestGenericVector()
        {
            var a = new GenericVector(4, 4);
            var b = new GenericVector(6, 6);

            Assert.Equal(GenericVector.Distance(a, b), Math.Sqrt(8.0));

            var c = GenericVector.Sum(a, new GenericVector(6, 6));
            var d = GenericVector.Sum(b, new GenericVector(4, 4));

            Assert.Equal(GenericVector.Distance(c, d), 0);
        }
Example #3
0
        private void RecalculateCentroids()
        {
            var newCentroids = new Dictionary <int, GenericVector>();

            foreach (var centroid in newCentroids)
            {
                var cluster = _dataSet.Where(x => x.Cluster == centroid.Key);
                var sum     = new GenericVector(cluster.First().Vector.Size);

                foreach (var clusterPoint in cluster)
                {
                    sum = GenericVector.Sum(sum, clusterPoint.Vector);
                }

                newCentroids[centroid.Key] = GenericVector.Devide(sum, cluster.Count());
            }
        }
Example #4
0
 public void UpdateAccumulatedValues(int actionId)
 {
     AccumulatedValues.Sum(
         CurrentNodesCollection[actionId].PersonalityModifiers.ToGenericVector());
 }