コード例 #1
0
        public void Slot_ExpectedBehavior()
        {
            // Arrange
            var builder = new DomainBuilder <MyContext>("Test");

            // Act
            builder.Slot(1);
            Assert.AreEqual(true, builder.Pointer is TaskRoot);

            var domain = builder.Build();

            var subDomain = new DomainBuilder <MyContext>("sub-domain").Build();

            Assert.IsTrue(domain.TrySetSlotDomain(1, subDomain));           // Its valid to add a sub-domain to a slot we have defined in our domain definition, and that is not currently occupied.
            Assert.IsTrue(domain.TrySetSlotDomain(1, subDomain) == false);  // Need to clear slot before we can attach sub-domain to a currently occupied slot.
            Assert.IsTrue(domain.TrySetSlotDomain(99, subDomain) == false); // Need to define slotId in domain definition before we can attach sub-domain to that slot.

            Assert.IsTrue(domain.Root.Subtasks.Count == 1);
            Assert.IsTrue(domain.Root.Subtasks[0] is Slot);

            var slot = (Slot)domain.Root.Subtasks[0];

            Assert.IsTrue(slot.Subtask != null);
            Assert.IsTrue(slot.Subtask is TaskRoot);
            Assert.IsTrue(slot.Subtask.Name == "sub-domain");

            domain.ClearSlot(1);
            Assert.IsTrue(slot.Subtask == null);
        }
        public void SelectorBuild_ForgotEnd()
        {
            // Arrange
            var builder = new DomainBuilder <MyContext>("Test");

            // Act
            builder.Select("select test");
            var domain = builder.Build();
        }
        public void BuildInvalidatesPointer_ForgotEnd()
        {
            // Arrange
            var builder = new DomainBuilder <MyContext>("Test");

            // Act
            var domain = builder.Build();

            Assert.IsTrue(builder.Pointer == domain.Root);
        }
        public void Build_ForgotEnd()
        {
            // Arrange
            var builder = new DomainBuilder <MyContext>("Test");

            // Act
            var ptr    = builder.Pointer;
            var domain = builder.Build();

            Assert.IsTrue(domain.Root != null);
            Assert.IsTrue(ptr == domain.Root);
            Assert.AreEqual("Test", domain.Root.Name);
        }
コード例 #5
0
        private static Domain <AIContext> DefineDomain(List <Item> itemsInScreen)
        {
            var itemDomainBuilder = new DomainBuilder <AIContext>("Item Sub-domains");

            foreach (var item in itemsInScreen)
            {
                itemDomainBuilder.Splice(item.Domain);
            }

            return(new DomainBuilder <AIContext>("Intro Screen Domain")
                   .Splice(itemDomainBuilder.Build())
                   .Action("Failed")
                   .Condition("Failed to address goal", (ctx => ctx.HasGoal(GoalState.None) == false))
                   .Do(Actions.Failed)
                   .Effect("Complete Goal", EffectType.PlanAndExecute, (ctx, type) => ctx.SetGoal(GoalState.None, true, type))
                   .End()
                   .Action("Idle")
                   .Do(ctx => TaskStatus.Continue)
                   .End()
                   .Build());
        }