本文整理汇总了C#中Agent.getBehaviourDict方法的典型用法代码示例。如果您正苦于以下问题:C# Agent.getBehaviourDict方法的具体用法?C# Agent.getBehaviourDict怎么用?C# Agent.getBehaviourDict使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Agent
的用法示例。
在下文中一共展示了Agent.getBehaviourDict方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: POSHAction
/// <summary>
/// Picks the given action from the given agent.
///
/// The method uses the agent's behaviour dictionary to get the
/// action method.
///
/// The log domain is set to "[AgentId].Action.[action_name]".
///
/// The action name is set to "[BehaviourName].[action_name]".
/// </summary>
/// <param name="agent">The agent that can perform the action.</param>
/// <param name="actionName">The name of the action</param>
public POSHAction(Agent agent, string actionName)
: base(string.Format("Action.{0}",actionName),agent)
{
behaviourDict = agent.getBehaviourDict();
action = behaviourDict.getAction(actionName);
behaviour = behaviourDict.getActionBehaviour(actionName);
name = string.Format("{0}.{1}",behaviour.GetName(),actionName);
log.Debug("Created");
}
示例2: POSHSense
/// <summary>
/// Picks the given sense or sense-act from the given agent.
///
/// The method uses the agent's behaviour dictionary to get the
/// sense / sense-act method.
///
/// The log domain is set to "[AgentId].Sense.[sense_name]".
///
/// The sense name is set to "[BehaviourName].[sense_name]".
/// </summary>
/// <param name="agent">The agent that can use the sense.</param>
/// <param name="senseName">The name of the sense</param>
/// <param name="value">The value to compare it to. This is given as a string,
/// but will be converted to an integer or float or boolean, or
/// left as a string, whatever is possible. If None is given
/// then the sense has to evaluate to True.</param>
/// <param name="predicate">"==", "!=", "<", ">", "<=", ">=". If null is
/// given, then "==" is assumed.</param>
public POSHSense(Agent agent, string senseName, string value = null, string predicate = null)
:base(string.Format("Sense.{0}",senseName),agent)
{
behaviourDict = agent.getBehaviourDict();
sense = behaviourDict.getSense(senseName);
behaviour = behaviourDict.getSenseBehaviour(senseName);
name = string.Format("{0}.{1}", behaviour.GetName(), senseName);
this.value = (value is string) ? AgentInitParser.strToValue(value) : null;
this.predicate = (predicate is string) ? predicate : "==";
log.Debug("Created");
}
示例3: checkNamesClashes
/// <summary>
/// Checks for naming clashes in actions / senses / action pattern /
/// competences.
/// </summary>
/// <param name="agent">The agent to check clashes for (as the agent provides
/// the behaviour dictionary).</param>
/// <exception cref="NameException">If a clash is detected.
/// </exception>
internal void checkNamesClashes(Agent agent)
{
BehaviourDict dict = agent.getBehaviourDict();
string [] actions = dict.getActionNames();
string [] senses = dict.getSenseNames();
foreach(string competence in this.competences.Keys)
{
if (actions.Contains(competence))
throw new NameException(string.Format("Competence name '{0}' clashes with " +
"action of same name", competence));
if (senses.Contains(competence))
throw new NameException(string.Format("Competence name '{0}' clashes with " +
"sense of same name", competence));
}
foreach(string actionpattern in this.actionPatterns.Keys)
{
if (actions.Contains(actionpattern))
throw new NameException(string.Format("Action pattern name '{0}' clashes with " +
"action of same name", actionpattern));
if (senses.Contains(actionpattern))
throw new NameException(string.Format("Action pattern name '{0}' clashes with " +
"sense of same name", actionpattern));
}
}
示例4: buildActionPatterns
/// <summary>
/// Completes the action pattern based on the given
/// action pattern stubs.
///
/// This method modifies the given action pattern stubs and
/// creates all its elements. The elements can either be other
/// competences, actions or senses, where competences are only
/// allowed as the last elements in action patterns. In case of
/// actions / senses, the corresponding POSH.strict.Action /
/// POSH.strict.Sense objects are created. The actions / senses have
/// to be available in the agent's behaviour dictionary.
/// </summary>
/// <param name="agent">The agent to build the competences for.</param>
/// <param name="competences">The competence stubs, as returned by
/// buildCompetenceStubs.</param>
/// <param name="actionPatterns">The action pattern stubs, as returned by
/// buildActionPatternStubs</param>
/// <returns></returns>
internal void buildActionPatterns(Agent agent, Dictionary<string,Competence> competences,
Dictionary<string,ActionPattern> actionPatterns)
{
string [] senseNames = agent.getBehaviourDict().getSenseNames();
foreach (string actionPattern in this.actionPatterns.Keys)
{
// create the elements of the action pattern
List<CopiableElement> elementList = new List<CopiableElement>();
object[] elementNames = this.actionPatterns[actionPattern].Third.ToArray();
// build all but the last element
for (int i = 0; i < elementNames.Length - 1; i++ )
{
if (elementNames[i] is string && senseNames.Contains(elementNames[i]))
//its in senses and a string -> sense-act
elementList.Add(buildSenseAct(agent,(string)elementNames[i]));
else if (elementNames[i] is Tuple<string,string,string>)
//its not a string -> sense
elementList.Add(buildSense(agent,(Tuple<string,string,string>)elementNames[i]));
else
//neither of above -> action
elementList.Add(getTriggerable(agent,(string)elementNames[i]));
}
// for the last element also allow competences
if (elementNames[elementNames.Length-1] is string && senseNames.Contains(elementNames[elementNames.Length-1]))
//its in senses and a string -> sense-act
elementList.Add(buildSenseAct(agent,(string)elementNames[elementNames.Length-1]));
else if (elementNames[elementNames.Length-1] is Tuple<string,string,string>)
//its not a string -> sense
elementList.Add(buildSense(agent,(Tuple<string,string,string>)elementNames[elementNames.Length-1]));
else
//neither of above -> action
elementList.Add(getTriggerable(agent,(string)elementNames[elementNames.Length-1],competences));
actionPatterns[actionPattern].SetElements(elementList.ToArray());
}
}