/// <summary>
        /// Assigns new decision option to mental model of current agent. If empty rooms ended, old decision options will be removed.
        /// </summary>
        /// <param name="newDecisionOption"></param>
        public void AssignNewDecisionOption(DecisionOption newDecisionOption)
        {
            DecisionOptionLayer layer = newDecisionOption.Layer;

            DecisionOption[] layerDecisionOptions = AssignedDecisionOptions.GroupBy(r => r.Layer).Where(g => g.Key == layer).SelectMany(g => g).ToArray();

            if (layerDecisionOptions.Length < layer.LayerConfiguration.MaxNumberOfDecisionOptions)
            {
                AssignedDecisionOptions.Add(newDecisionOption);
                AnticipationInfluence.Add(newDecisionOption, new Dictionary <Goal, double>());

                DecisionOptionActivationFreshness[newDecisionOption] = 0;
            }
            else
            {
                DecisionOption decisionOptionForRemoving = DecisionOptionActivationFreshness.Where(kvp => kvp.Key.Layer == layer).GroupBy(kvp => kvp.Value).OrderByDescending(g => g.Key)
                                                           .Take(1).SelectMany(g => g.Select(kvp => kvp.Key)).RandomizeOne();

                AssignedDecisionOptions.Remove(decisionOptionForRemoving);
                AnticipationInfluence.Remove(decisionOptionForRemoving);

                DecisionOptionActivationFreshness.Remove(decisionOptionForRemoving);

                AssignNewDecisionOption(newDecisionOption);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Adds layer to the decision option set.
        /// </summary>
        /// <param name="layer"></param>
        public void Add(DecisionOptionLayer layer)
        {
            layerIndexer++;
            layer.Set            = this;
            layer.PositionNumber = layerIndexer;

            Layers.Add(layer);
        }
        /// <summary>
        /// Adds decision option to mental model of current prototype if it isn't exists in the scope.
        /// </summary>
        /// <param name="newDecisionOption"></param>
        /// <param name="layer"></param>
        public void AddNewDecisionOption(DecisionOption newDecisionOption, DecisionOptionLayer layer)
        {
            if (mentalProto == null)
            {
                TransformDOToMentalModel();
            }

            layer.Add(newDecisionOption);

            DecisionOptions.Add(newDecisionOption);
        }
        /// <summary>
        /// Adds decision option to agent archetype and then assign one to the decision option list of current agent.
        /// Also copies anticipated influence to the agent.
        /// </summary>
        /// <param name="newDecisionOption"></param>
        /// <param name="layer"></param>
        /// <param name="anticipatedInfluence"></param>
        public void AddDecisionOption(DecisionOption newDecisionOption, DecisionOptionLayer layer, Dictionary <Goal, double> anticipatedInfluence)
        {
            Archetype.AddNewDecisionOption(newDecisionOption, layer);

            AssignNewDecisionOption(newDecisionOption, anticipatedInfluence);
        }
        /// <summary>
        /// Adds decision option to agent archetype and then assign one to the decision option list of current agent.
        /// </summary>
        /// <param name="newDecisionOption"></param>
        /// <param name="layer"></param>
        public void AddDecisionOption(DecisionOption newDecisionOption, DecisionOptionLayer layer)
        {
            Archetype.AddNewDecisionOption(newDecisionOption, layer);

            AssignNewDecisionOption(newDecisionOption);
        }