Beispiel #1
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);
 }
Beispiel #2
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);
        }
Beispiel #3
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);
        }
Beispiel #4
0
        /// <summary>
        ///   Initializes a new instance of the <see cref="AiConstructor"/> class.
        /// </summary>
        /// <param name="collection">The collection.</param>
        /// <exception cref="Crystal.AiConstructor.AiCollectionNullException"></exception>
        protected AiConstructor(IAiCollection collection)
        {
            if (collection == null)
            {
                throw new AiCollectionNullException();
            }

            AIs = collection;
            Initialize();
        }
Beispiel #5
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();
        }
Beispiel #6
0
        /// <summary>
        /// Copy constructor.
        /// </summary>
        /// <param name="other">The other.</param>
        UtilityAi(UtilityAi other)
        {
            NameId      = other.NameId;
            _collection = other._collection;
            Initialize();
            _selector = other._selector.Clone();

            for (int i = 0; i < other._behaviours.Count; i++)
            {
                var b = other._behaviours[i].Clone() as Behaviour;
                _behaviours.Add(b);
                _behaviourUtilities.Add(b.Utility);
            }
        }
Beispiel #7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AiTransition"/> class.
        /// </summary>
        /// <param name="nameId">The name identifier.</param>
        /// <param name="aiNameId">The ai name identifier.</param>
        /// <param name="collection">The collection.</param>
        /// <exception cref="Crystal.ActionBase.NameIdEmptyOrNullException">
        /// </exception>
        public AiTransition(string nameId, string aiNameId, IAiCollection collection) : base(nameId, collection?.Actions)
        {
            if (string.IsNullOrEmpty(nameId))
            {
                throw new NameIdEmptyOrNullException();
            }
            if (string.IsNullOrEmpty(aiNameId))
            {
                throw new NameIdEmptyOrNullException();
            }

            NameId        = nameId;
            _aiNameId     = aiNameId;
            _aiCollection = collection;
        }
Beispiel #8
0
        /// <summary>
        /// Initializes a new instance of the <see cref="UtilityAi"/> class.
        /// </summary>
        /// <param name="nameId">The name identifier.</param>
        /// <param name="collection">The collection.</param>
        /// <exception cref="Crystal.UtilityAi.NameIdIsNullOrEmptyException"></exception>
        /// <exception cref="Crystal.UtilityAi.AiCollectionNullException"></exception>
        /// <exception cref="Crystal.UtilityAi.AiAlreadyExistsInCollectionException"></exception>
        public UtilityAi(string nameId, IAiCollection collection)
        {
            if (string.IsNullOrEmpty(nameId))
            {
                throw new NameIdIsNullOrEmptyException();
            }
            if (collection == null)
            {
                throw new AiCollectionNullException();
            }

            NameId      = nameId;
            _collection = collection;
            Initialize();
            if (_collection.Add(this) == false)
            {
                throw new AiAlreadyExistsInCollectionException(nameId);
            }
        }
Beispiel #9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AiTransition"/> class.
 /// </summary>
 /// <param name="other">The other.</param>
 AiTransition(AiTransition other) : base(other)
 {
     _aiNameId     = other._aiNameId;
     _aiCollection = other._aiCollection;
 }
Beispiel #10
0
 public ExAiConstructor(IAiCollection collection) : base(collection)
 {
 }
 public MasterAiConstructor(IAiCollection collection) : base(collection)
 {
 }
Beispiel #12
0
 public HelperAiConstructor(IAiCollection collection) : base(collection)
 {
 }