public void Initialize()
 {
     _actions        = new ActionCollection();
     _considerations = new ConsiderationCollection();
     _options        = new OptionCollection(_actions, _considerations);
     _behaviours     = new BehaviourCollection(_options);
 }
Пример #2
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);
 }
Пример #3
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);
        }
Пример #4
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);
        }
Пример #5
0
        /// <summary>
        ///   Initializes a new instance of the <see cref="AiCollection"/> class.
        /// </summary>
        /// <param name="behaviourCollection">The behaviour collection.</param>
        /// <exception cref="Crystal.AiCollection.BehaviourCollectionNullException"></exception>
        public AiCollection(IBehaviourCollection behaviourCollection)
        {
            if (behaviourCollection == null)
            {
                throw new BehaviourCollectionNullException();
            }

            _aiMap     = new Dictionary <string, IUtilityAi>();
            Behaviours = behaviourCollection;
        }
Пример #6
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);
        }
Пример #7
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();
        }
Пример #8
0
        /// <summary>
        /// Initializes a new instance of the <see cref="BehaviourTransition"/> class.
        /// </summary>
        /// <param name="nameId">The name identifier.</param>
        /// <param name="behaviourId">The behaviour identifier.</param>
        /// <param name="collection">The collection.</param>
        /// <exception cref="Crystal.ActionBase.NameIdEmptyOrNullException"></exception>
        public BehaviourTransition(string nameId, string behaviourId, IBehaviourCollection collection)
            : base(nameId, collection?.Options?.Actions)
        {
            if (string.IsNullOrEmpty(behaviourId))
            {
                throw new NameIdEmptyOrNullException();
            }

            _behaviourId         = behaviourId;
            _behaviourCollection = collection;
        }
Пример #9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Behaviour"/> class.
        /// </summary>
        /// <param name="other">The other.</param>
        Behaviour(Behaviour other) : base(other)
        {
            CreateLists();
            _collection = other._collection;
            _selector   = other.Selector.Clone();
            Measure     = other.Measure.Clone();

            for (int i = 0; i < other._options.Count; i++)
            {
                var o = other._options[i].Clone() as IOption;
                _options.Add(o);
                _optionUtilities.Add(o.Utility);
            }
        }
Пример #10
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Behaviour"/> class.
        /// </summary>
        /// <param name="nameId">The name identifier.</param>
        /// <param name="collection">The collection.</param>
        /// <exception cref="Crystal.Behaviour.BehaviourCollectionNullException"></exception>
        /// <exception cref="Crystal.Behaviour.BehaviourAlreadyExistsInCollectionException"></exception>
        public Behaviour(string nameId, IBehaviourCollection collection) : base(collection?.Options?.Considerations)
        {
            if (collection == null)
            {
                throw new BehaviourCollectionNullException();
            }

            NameId      = nameId;
            _collection = collection;
            Initialize();
            if (_collection.Add(this) == false)
            {
                throw new BehaviourAlreadyExistsInCollectionException(nameId);
            }
        }
Пример #11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BehaviourTransition"/> class.
 /// </summary>
 /// <param name="other">The other.</param>
 BehaviourTransition(BehaviourTransition other) : base(other)
 {
     _behaviourId         = other._behaviourId;
     _behaviourCollection = other._behaviourCollection;
 }