public void Initialize()
 {
     _actions        = new ActionCollection();
     _considerations = new ConsiderationCollection();
     _options        = new OptionCollection(_actions, _considerations);
     _behaviours     = new BehaviourCollection(_options);
 }
Пример #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:Crystal.Option"/> class.
 /// </summary>
 /// <param name="other">The other.</param>
 protected Option(Option other) : base(other)
 {
     _collection = other._collection;
     Weight      = other.Weight;
     Measure     = other.Measure?.Clone();
     Action      = other.Action?.Clone();
 }
Пример #3
0
        /// <summary>
        ///   Creates an <see cref="T:Crystal.IOption"/> that uses the <see cref="T:Crystal.Chebyshev"/>
        ///   measure.
        /// </summary>
        /// <param name="optionId">The option identifier.</param>
        /// <param name="collection">The collection.</param>
        /// <returns></returns>
        public static IOption Chebyshev(string optionId, IOptionCollection collection)
        {
            var option = new Option(optionId, collection);

            option.Measure = new Chebyshev();
            return(option);
        }
Пример #4
0
        /// <summary>
        ///   Creates an <see cref="T:Crystal.IOption"/> that uses the <see cref="T:Crystal.WeightedMetrics"/>
        ///   measure.
        /// </summary>
        /// <param name="optionId">The option identifier.</param>
        /// <param name="collection">The collection.</param>
        /// <param name="pNorm">The p norm.</param>
        /// <returns></returns>
        public static IOption WeightedMetrics(string optionId, IOptionCollection collection,
                                              float pNorm = 2.0f)
        {
            var option = new Option(optionId, collection);

            option.Measure = new WeightedMetrics(pNorm);
            return(option);
        }
Пример #5
0
        /// <summary>
        ///   Creates an <see cref="T:Crystal.IOption"/> that uses the <see cref="T:Crystal.ConstrainedChebyshev"/>
        ///   measure.
        /// </summary>
        /// <param name="optionId">The option identifier.</param>
        /// <param name="collection">The collection.</param>
        /// <param name="lowerBound">The lower bound.</param>
        /// <returns></returns>
        public static IOption ConstrainedChebyshev(string optionId, IOptionCollection collection,
                                                   float lowerBound = 0.0f)
        {
            var option = new Option(optionId, collection);

            option.Measure = new ConstrainedChebyshev(lowerBound);
            return(option);
        }
Пример #6
0
        /// <summary>
        ///   Creates an <see cref="T:Crystal.IOption"/> that uses the <see cref="T:Crystal.ConstrainedWeightedMetrics"/>
        ///   measure.
        /// </summary>
        /// <param name="optionId">The option identifier.</param>
        /// <param name="collection">The collection.</param>
        /// <param name="pNorm">The p norm.</param>
        /// <param name="lowerBound">The lower bound.</param>
        /// <returns></returns>
        public static IOption ConstrainedWeightedMetrics(string optionId, IOptionCollection collection,
                                                         float pNorm = 2.0f, float lowerBound = 0.0f)
        {
            var option = new Option(optionId, collection);

            option.Measure = new ConstrainedWeightedMetrics(pNorm, lowerBound);
            return(option);
        }
Пример #7
0
 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);
 }
Пример #8
0
        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);
        }
Пример #9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:Crystal.Option"/> class.
 /// </summary>
 /// <param name="nameId">The name identifier.</param>
 /// <param name="collection">The collection.</param>
 /// <exception cref="T:Crystal.Option.OptionAlreadyExistsInCollectionException"></exception>
 public Option(string nameId, IOptionCollection collection) : base(collection?.Considerations)
 {
     _collection = collection;
     NameId      = nameId;
     Initialize();
     if (_collection.Add(this) == false)
     {
         throw new OptionAlreadyExistsInCollectionException(nameId);
     }
 }
Пример #10
0
        /// <summary>
        /// Initializes a new instance of the <see cref="BehaviourCollection"/> class.
        /// </summary>
        /// <param name="optionCollection">The option collection.</param>
        /// <exception cref="Crystal.BehaviourCollection.OptionCollectionNullException"></exception>
        public BehaviourCollection(IOptionCollection optionCollection)
        {
            if (optionCollection == null)
            {
                throw new OptionCollectionNullException();
            }

            _behavioursMap = new Dictionary <string, IBehaviour>();
            Options        = optionCollection;
        }
Пример #11
0
        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);
        }
Пример #12
0
        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);
        }
Пример #13
0
        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();
        }
Пример #14
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ConstantUtilityOption"/> class.
 /// </summary>
 /// <param name="nameId">The name identifier.</param>
 /// <param name="collection">The collection.</param>
 public ConstantUtilityOption(string nameId, IOptionCollection collection) : base(nameId, collection)
 {
 }
Пример #15
0
 public void Initialize()
 {
     _ac = new ActionCollection();
     _cc = new ConsiderationCollection();
     _oc = new OptionCollection(_ac, _cc);
 }
Пример #16
0
 public RecursiveOption(string nameId, IOptionCollection collection) : base(nameId, collection)
 {
 }
Пример #17
0
 public BehaviourCollection(IOptionCollection options)
 {
     m_behaviours = new Dictionary <string, IBehaviour>();
     Options      = options;
 }
Пример #18
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:Crystal.Option"/> class with <see cref="T:Crystal.IParameterProvider"/> parameters.
 /// </summary>
 /// <param name="nameId">The name identifier.</param>
 /// <param name="collection">The collection.</param>
 /// <param name="parameters">The parameters.</param>
 /// <exception cref="T:Crystal.Option.OptionAlreadyExistsInCollectionException"></exception>
 public Option(string nameId, IOptionCollection collection, IParameterProvider parameters) : this(nameId, collection)
 {
     Parameters = parameters;
 }