Beispiel #1
0
        /// <summary>
        /// A POSH competence, containing competence priority elements.
        /// 
        /// Initialises the competence.
        /// 
        /// If no goal is given, then the goal will never be reached.
        /// 
        /// The log domain is set to "[AgentId].C.[competence_name]".
        /// </summary>
        /// <param name="agent">The competence's agent.</param>
        /// <param name="competenceName">The name of the competence.</param>
        /// <param name="priorityElements">The priority elements of the competence,
        ///         in their order of priority.</param>
        /// <param name="goal">The goal of the competence.</param>
        public Competence(Agent agent, string competenceName, CompetencePriorityElement[] priorityElements, Trigger goal)
            : base(string.Format("C.{0}",competenceName),agent)
        {
            this.name = competenceName;
            if (priorityElements.Length > 0 )
                this.elements = new List<CompetencePriorityElement>(priorityElements);
            else
                this.elements = new List<CompetencePriorityElement>();
            this.goal = goal;

            log.Debug("Created");
        }
Beispiel #2
0
        /// <summary>
        /// Returns a reset copy of itsself.
        ///
        /// This method creates a copy of itsself that has a copy of the
        /// reset priority elements but is otherwise equal.
        /// </summary>
        /// <returns></returns>
        public override CopiableElement  copy()
        {
            // everything besides the elements stays the same. That's why
            // we make a shallow copy and only copy the elements separately.

            CompetencePriorityElement newObj      = (CompetencePriorityElement)this.MemberwiseClone();
            List <CompetenceElement>  newElements = new List <CompetenceElement>();

            foreach (CompetenceElement elem in elements)
            {
                newElements.Add((CompetenceElement)elem.copy());
            }
            newObj.elements = newElements;

            return(newObj);
        }
Beispiel #3
0
 /// <summary>
 /// Sets the list of priority elements of the competence.
 /// 
 /// Calling this method also resets the competence.
 /// </summary>
 /// <param name="elements"></param>
 public void setElements(CompetencePriorityElement[] elements)
 {
     this.elements = new List<CompetencePriorityElement>(elements);
     reset();
 }