public void Initialize() { _actions = new ActionCollection(); _considerations = new ConsiderationCollection(); _options = new OptionCollection(_actions, _considerations); _behaviours = new BehaviourCollection(_options); }
public void FillCollections(ref IActionCollection actionCollection, ref IConsiderationCollection considerationCollection) { foreach (var keyvalue in m_loaders) { var key = keyvalue.Key; var loader = keyvalue.Value; var dicoActions = loader.Actions; foreach (var keyvalueAction in dicoActions) { var keyAction = keyvalueAction.Key; var deleg = keyvalueAction.Value; var id = new InfoId() { NamespaceId = key, NameId = keyAction }; var newAction = new DynamicAction(id, deleg); //actionCollection.Add(newAction); } var dicoConsiderations = loader.Considerations; foreach (var keyvalueConsideration in dicoConsiderations) { var keyConsideration = keyvalueConsideration.Key; var deleg = keyvalueConsideration.Value; var id = new InfoId() { NamespaceId = key, NameId = keyConsideration }; var newConsideration = new DynamicConsideration(id, deleg); //considerationCollection.Add(newConsideration); } } }
/// <summary> /// Initializes a new instance of the <see cref="T:Crystal.ConsiderationBase`1"/> class. /// </summary> /// <param name="other">The other.</param> protected ConsiderationBase(ConsiderationBase <TContext> other) { _collection = other._collection; NameId = other.NameId; DefaultUtility = other.DefaultUtility; Utility = other.Utility; Weight = other.Weight; }
/// <summary> /// Initializes a new instance of the <see cref="T:Crystal.ConsiderationBase"/> class. /// </summary> /// <param name="other">The other.</param> protected ConsiderationBase(ConsiderationBase other) { _collection = other._collection; NameId = other.NameId; DefaultUtility = other.DefaultUtility; Utility = other.Utility; Weight = other.Weight; Parameters = other.Parameters?.Clone(); }
public void Initialize() { _actions = new ActionCollection(); _considerations = new ConsiderationCollection(); _options = new OptionCollection(_actions, _considerations); _behaviours = new BehaviourCollection(_options); _aIs = new AiCollection(_behaviours); _ctor = new MasterAiConstructor(_aIs); }
/// <summary> /// Creates a composite consideration using the <see cref="T:Crystal.Chebyshev"/> measure. /// </summary> /// <param name="nameId">The name identifier.</param> /// <param name="collection">The collection.</param> public static ICompositeConsideration Chebyshev(string nameId, IConsiderationCollection collection) { var consideration = new CompositeConsideration(nameId, collection) { Measure = new Chebyshev() }; return(consideration); }
/// <summary> /// Creates a composite consideration using the <see cref="T:Crystal.MultiplicativePseudoMeasure"/>. /// </summary> /// <param name="nameId">The name identifier.</param> /// <param name="collection">The collection.</param> public static ICompositeConsideration Multiplicative(string nameId, IConsiderationCollection collection) { var consideration = new CompositeConsideration(nameId, collection) { Measure = new MultiplicativePseudoMeasure() }; return(consideration); }
/// <summary> /// Initializes a new instance of the <see cref="T:Crystal.CompositeConsideration"/> class. /// </summary> /// <param name="collection">The collection.</param> /// <exception cref="T:Crystal.CompositeConsideration.ConsiderationCollectionNullException"></exception> protected CompositeConsideration(IConsiderationCollection collection) { if (collection == null) { throw new ConsiderationCollectionNullException(); } _collection = collection; Initialize(); }
public void Initialize() { _actions = new ActionCollection(); _considerations = new ConsiderationCollection(); _options = new OptionCollection(_actions, _considerations); _behaviours = new BehaviourCollection(_options); _aIs = new AiCollection(_behaviours); _utilityAi = new UtilityAi("ai0", _aIs); }
/// <summary> /// Creates a composite consideration using the <see cref="T:Crystal.ConstrainedChebyshev"/> pseudo-measure. /// </summary> /// <param name="nameId">The name identifier.</param> /// <param name="collection">The collection.</param> /// <param name="lowerBound">The lower bound.</param> public static ICompositeConsideration ConstrainedChebyshev(string nameId, IConsiderationCollection collection, float lowerBound = 0.0f) { var consideration = new CompositeConsideration(nameId, collection) { Measure = new ConstrainedChebyshev(lowerBound) }; return(consideration); }
/// <summary> /// Creates a composite consideration using the <see cref="T:Crystal.WeightedMetrics"/> measure. /// </summary> /// <param name="nameId">The name identifier.</param> /// <param name="collection">The collection.</param> /// <param name="pNorm">The p norm.</param> public static ICompositeConsideration WeightedMetrics(string nameId, IConsiderationCollection collection, float pNorm = 2.0f) { var consideration = new CompositeConsideration(nameId, collection) { Measure = new WeightedMetrics(pNorm) }; return(consideration); }
/// <summary> /// Creates a composite consideration using the given measure. /// </summary> /// <param name="nameId">The name identifier.</param> /// <param name="collection">The collection.</param> /// <param name="measure">The measure.</param> public static ICompositeConsideration Create(string nameId, IConsiderationCollection collection, IMeasure measure) { var consideration = new CompositeConsideration(nameId, collection) { Measure = measure }; return(consideration); }
public AiCollection(Info.AiInfoDatabase db) { m_ais = new Dictionary <string, IUtilityAi>(); m_actions = new ActionCollection(); m_considerations = new ConsiderationCollection(); m_options = new OptionCollection(Actions, Considerations); m_behaviours = new BehaviourCollection(Options); Populate(db); }
public void Initialize() { _ac = new ActionCollection(); _cc = new ConsiderationCollection(); _oc = new OptionCollection(_ac, _cc); _bc = new BehaviourCollection(_oc); _aic = new AiCollection(_bc); var b = new Behaviour("b1", _bc); }
public void Inititalize() { _toon = new Toon(); _ac = new ActionCollection(); _cc = new ConsiderationCollection(); _oc = new OptionCollection(_ac, _cc); _bc = new BehaviourCollection(_oc); _aic = new AiCollection(_bc); // The main AI _ai = new UtilityAi("ai", _aic); var coreBehaviour = new Behaviour("coreBehaviour", _bc); coreBehaviour.Selector = new MaxUtilitySelector(); _ai.AddBehaviour(coreBehaviour.NameId); // Eat Option _eatOption = new Option(); _eatOption.Measure = new WeightedMetrics(1.4f); var eatAction = new EatAction(); var hungerConsideration = new HungerConsideration(); (_eatOption as Option).SetAction(eatAction); _eatOption.AddConsideration(hungerConsideration); _eatOption.AddConsideration(new InverseBladderConsideration()); coreBehaviour.AddConsideration(_eatOption); // Drink Option _drinkOption = new Option(); _drinkOption.Measure = new WeightedMetrics(3.0f); var drinkAction = new DrinkAction(); var thirstConsideration = new ThirstConsideration(); (_drinkOption as Option).SetAction(drinkAction); _drinkOption.AddConsideration(thirstConsideration); _drinkOption.AddConsideration(new InverseBladderConsideration()); // Toilet Option _toiletOption = new Option(); _toiletOption.Measure = new WeightedMetrics(); var toiletAction = new ToiletAction(); var bladderConsideration = new BladderConsideration(); (_toiletOption as Option).SetAction(toiletAction); _toiletOption.AddConsideration(bladderConsideration); coreBehaviour.AddConsideration(_eatOption); coreBehaviour.AddConsideration(_drinkOption); coreBehaviour.AddConsideration(_toiletOption); Console.WriteLine(coreBehaviour); _scheduler = new Scheduler(); }
/// <summary> /// Initializes a new instance of the <see cref="T:Crystal.ConsiderationBase`1"/> class. /// </summary> /// <param name="nameId">The name identifier.</param> /// <param name="collection">The collection.</param> /// <exception cref="T:Crystal.ConsiderationBase`1.ConsiderationCollectionNullException"></exception> /// <exception cref="T:Crystal.ConsiderationBase`1.ConsiderationAlreadyExistsInCollectionException"></exception> protected ConsiderationBase(string nameId, IConsiderationCollection collection) { if (collection == null) { throw new ConsiderationCollectionNullException(); } NameId = nameId; _collection = collection; if (_collection.Add(this) == false) { throw new ConsiderationAlreadyExistsInCollectionException(nameId); } }
/// <summary> /// Initializes a new instance of the <see cref="OptionCollection"/> class. /// </summary> /// <param name="actionCollection">The action collection.</param> /// <param name="considerationCollection">The consideration collection.</param> /// <exception cref="T:Crystal.OptionCollection.ActionCollectionNullException"></exception> /// <exception cref="T:Crystal.OptionCollection.ConsiderationCollectionNullException"></exception> public OptionCollection(IActionCollection actionCollection, IConsiderationCollection considerationCollection) { if (actionCollection == null) { throw new ActionCollectionNullException(); } if (considerationCollection == null) { throw new ConsiderationCollectionNullException(); } _optionsMap = new Dictionary <string, IOption>(); Actions = actionCollection; Considerations = considerationCollection; }
/// <summary> /// Initializes a new instance of the <see cref="T:Crystal.CompositeConsideration"/> class. /// </summary> /// <param name="other">The other.</param> protected CompositeConsideration(CompositeConsideration other) { CreateLists(); NameId = other.NameId; _collection = other._collection; _measure = other._measure.Clone(); _defaultUtility = other._defaultUtility; Utility = other.Utility; Weight = other.Weight; for (int i = 0; i < other._considerations.Count; i++) { _considerations.Add(other._considerations[i].Clone()); _considerationUtilities.Add(other._considerationUtilities[i]); } }
/// <summary> /// Initializes a new instance of the <see cref="CompositeConsideration"/> class. /// </summary> /// <param name="nameId">The name identifier.</param> /// <param name="collection">The collection.</param> /// <exception cref="T:Crystal.CompositeConsideration.NameIdIsNullOrEmptyException"></exception> /// <exception cref="T:Crystal.CompositeConsideration.ConsiderationCollectionNullException"></exception> /// <exception cref="T:Crystal.CompositeConsideration.NameIdAlreadyExistsInCollectionException"></exception> public CompositeConsideration(string nameId, IConsiderationCollection collection) { if (string.IsNullOrEmpty(nameId)) { throw new NameIdIsNullOrEmptyException(); } if (collection == null) { throw new ConsiderationCollectionNullException(); } NameId = nameId; _collection = collection; Initialize(); if (_collection.Add(this) == false) { throw new NameIdAlreadyExistsInCollectionException(nameId); } }
public void FillCollections(ref IActionCollection actionCollection, ref IConsiderationCollection considerationCollection) { for (int i = 0, iLength = m_actionContextNames.Length; i < iLength; ++i) { var contextName = m_actionContextNames[i]; for (int j = 0, jLength = m_actionNames[i].Length; j < jLength; ++j) { var actionName = m_actionNames[i][j]; var action = m_loader.GetAction(contextName, actionName); if (action == null) { throw new System.NullReferenceException(); } actionCollection.Add(action, new IdInfoIndex(i, j)); } } for (int i = 0, iLength = m_considerationContextNames.Length; i < iLength; ++i) { var contextName = m_considerationContextNames[i]; for (int j = 0, jLength = m_considerationNames[i].Length; j < jLength; ++j) { var considerationName = m_considerationNames[i][j]; var consideration = m_loader.GetConsideration(contextName, considerationName); if (consideration == null) { throw new System.NullReferenceException(); } considerationCollection.Add(consideration, new IdInfoIndex(i, j)); } } }
public HowUnfitConsideration(IConsiderationCollection collection) : base(Name, collection) { Initialize(); }
/// <summary> /// Initializes a new instance of the <see cref="T:Crystal.ConsiderationBase"/> class. /// </summary> /// <param name="nameId">The name identifier.</param> /// <param name="collection">The collection.</param> /// <param name="parameters">The parameters.</param> /// <exception cref="T:Crystal.ConsiderationBase.ConsiderationCollectionNullException"></exception> /// <exception cref="T:Crystal.ConsiderationBase.ConsiderationAlreadyExistsInCollectionException"></exception> protected ConsiderationBase(string nameId, IConsiderationCollection collection, IParameterProvider parameters) : this(nameId, collection) { Parameters = parameters; }
public HungerConsideration(IConsiderationCollection collection) : base(Name, collection) { Initialize(); }
public void Initialize() { _ac = new ActionCollection(); _cc = new ConsiderationCollection(); _oc = new OptionCollection(_ac, _cc); }
public OptionParametersConsideration(string nameId, IConsiderationCollection collection) : base(nameId, collection) { Initialize(); }
public CuriosityConsideration(IConsiderationCollection collection) : base(Name, collection) { }
public void Initialize() { _considerations = new ConsiderationCollection(); }
public ThirstConsideration(IConsiderationCollection collection) : base(Name, collection) { Initialize(); }
public GreedConsideration(IConsiderationCollection collection) : base(Name, collection) { Initialize(); }
public MockConsideration(string nameId, IConsiderationCollection collection) : base(nameId, collection) { Initialize(); }