コード例 #1
0
        void GenerateArgumentPermutations(StateData stateData, NativeList <ActionKey> argumentPermutations)
        {
            CharacterObjectIndices.Clear();
            stateData.GetTraitBasedObjectIndices(CharacterObjectIndices, CharacterFilter);

            ItemObjectIndices.Clear();
            stateData.GetTraitBasedObjectIndices(ItemObjectIndices, ItemFilter);

            var CharacterBuffer = stateData.CharacterBuffer;
            var CarriableBuffer = stateData.CarriableBuffer;
            var CarrierBuffer   = stateData.CarrierBuffer;
            var PositionBuffer  = stateData.PositionBuffer;



            for (int i0 = 0; i0 < CharacterObjectIndices.Length; i0++)
            {
                var CharacterIndex  = CharacterObjectIndices[i0];
                var CharacterObject = stateData.TraitBasedObjects[CharacterIndex];



                if (!(CarrierBuffer[CharacterObject.CarrierIndex].Carried == TraitBasedObjectId.None))
                {
                    continue;
                }



                for (int i1 = 0; i1 < ItemObjectIndices.Length; i1++)
                {
                    var ItemIndex  = ItemObjectIndices[i1];
                    var ItemObject = stateData.TraitBasedObjects[ItemIndex];

                    if (!(CharacterBuffer[CharacterObject.CharacterIndex].Waypoint == PositionBuffer[ItemObject.PositionIndex].Waypoint))
                    {
                        continue;
                    }

                    if (!(CarriableBuffer[ItemObject.CarriableIndex].CarriedBy == TraitBasedObjectId.None))
                    {
                        continue;
                    }



                    var actionKey = new ActionKey(k_MaxArguments)
                    {
                        ActionGuid         = ActionGuid,
                        [k_CharacterIndex] = CharacterIndex,
                        [k_ItemIndex]      = ItemIndex,
                    };
                    argumentPermutations.Add(actionKey);
                }
            }
        }
コード例 #2
0
        void GenerateArgumentPermutations(StateData stateData, NativeList <ActionKey> argumentPermutations)
        {
            var NPCFilter = new NativeArray <ComponentType>(3, Allocator.Temp)
            {
                [0] = ComponentType.ReadWrite <AI.Planner.Domains.Baggage>(), [1] = ComponentType.ReadWrite <Unity.AI.Planner.DomainLanguage.TraitBased.Location>(), [2] = ComponentType.ReadWrite <AI.Planner.Domains.Npc>(),
            };
            var ItemFilter = new NativeArray <ComponentType>(2, Allocator.Temp)
            {
                [0] = ComponentType.ReadWrite <Unity.AI.Planner.DomainLanguage.TraitBased.Location>(), [1] = ComponentType.ReadWrite <AI.Planner.Domains.Item>(),
            };
            var NPCObjectIndices = new NativeList <int>(2, Allocator.Temp);

            stateData.GetTraitBasedObjectIndices(NPCObjectIndices, NPCFilter);
            var ItemObjectIndices = new NativeList <int>(2, Allocator.Temp);

            stateData.GetTraitBasedObjectIndices(ItemObjectIndices, ItemFilter);
            var LocationBuffer = stateData.LocationBuffer;
            var BaggageBuffer  = stateData.BaggageBuffer;

            for (int i0 = 0; i0 < NPCObjectIndices.Length; i0++)
            {
                var NPCIndex  = NPCObjectIndices[i0];
                var NPCObject = stateData.TraitBasedObjects[NPCIndex];


                if (!(BaggageBuffer[NPCObject.BaggageIndex].HasItem == false))
                {
                    continue;
                }

                for (int i1 = 0; i1 < ItemObjectIndices.Length; i1++)
                {
                    var ItemIndex  = ItemObjectIndices[i1];
                    var ItemObject = stateData.TraitBasedObjects[ItemIndex];

                    if (!(LocationBuffer[NPCObject.LocationIndex].Position == LocationBuffer[ItemObject.LocationIndex].Position))
                    {
                        continue;
                    }


                    var actionKey = new ActionKey(k_MaxArguments)
                    {
                        ActionGuid    = ActionGuid,
                        [k_NPCIndex]  = NPCIndex,
                        [k_ItemIndex] = ItemIndex,
                    };
                    argumentPermutations.Add(actionKey);
                }
            }
            NPCObjectIndices.Dispose();
            ItemObjectIndices.Dispose();
            NPCFilter.Dispose();
            ItemFilter.Dispose();
        }
コード例 #3
0
        public bool IsTerminal(StateData stateData)
        {
            var CleaningFilter = new NativeArray <ComponentType>(1, Allocator.Temp)
            {
                [0] = ComponentType.ReadWrite <Cleanliness>(),
            };
            var CleaningObjectIndices = new NativeList <int>(2, Allocator.Temp);

            stateData.GetTraitBasedObjectIndices(CleaningObjectIndices, CleaningFilter);
            var RobotFilter = new NativeArray <ComponentType>(1, Allocator.Temp)
            {
                [0] = ComponentType.ReadWrite <Robot>(),
            };
            var RobotObjectIndices = new NativeList <int>(2, Allocator.Temp);

            stateData.GetTraitBasedObjectIndices(RobotObjectIndices, RobotFilter);
            var CleanlinessBuffer = stateData.CleanlinessBuffer;
            var RobotBuffer       = stateData.RobotBuffer;

            for (int i0 = 0; i0 < CleaningObjectIndices.Length; i0++)
            {
                var CleaningIndex  = CleaningObjectIndices[i0];
                var CleaningObject = stateData.TraitBasedObjects[CleaningIndex];


                if (!(CleanlinessBuffer[CleaningObject.CleanlinessIndex].DirtCount == 0))
                {
                    continue;
                }

                for (int i1 = 0; i1 < RobotObjectIndices.Length; i1++)
                {
                    var RobotIndex  = RobotObjectIndices[i1];
                    var RobotObject = stateData.TraitBasedObjects[RobotIndex];



                    if (!(RobotBuffer[RobotObject.RobotIndex].Battery > 0))
                    {
                        continue;
                    }
                    CleaningObjectIndices.Dispose();
                    CleaningFilter.Dispose();
                    RobotObjectIndices.Dispose();
                    RobotFilter.Dispose();
                    return(true);
                }
            }
            CleaningObjectIndices.Dispose();
            CleaningFilter.Dispose();
            RobotObjectIndices.Dispose();
            RobotFilter.Dispose();

            return(false);
        }
コード例 #4
0
        void GenerateArgumentPermutations(StateData stateData, NativeList <ActionKey> argumentPermutations)
        {
            var RobotFilter = new NativeArray <ComponentType>(2, Allocator.Temp)
            {
                [0] = ComponentType.ReadWrite <Unity.AI.Planner.DomainLanguage.TraitBased.Location>(), [1] = ComponentType.ReadWrite <Generated.AI.Planner.StateRepresentation.Robot>(),
            };
            var DirtFilter = new NativeArray <ComponentType>(2, Allocator.Temp)
            {
                [0] = ComponentType.ReadWrite <Unity.AI.Planner.DomainLanguage.TraitBased.Location>(), [1] = ComponentType.ReadWrite <Generated.AI.Planner.StateRepresentation.Dirt>(),
            };
            var RobotObjectIndices = new NativeList <int>(2, Allocator.Temp);

            stateData.GetTraitBasedObjectIndices(RobotObjectIndices, RobotFilter);

            var DirtObjectIndices = new NativeList <int>(2, Allocator.Temp);

            stateData.GetTraitBasedObjectIndices(DirtObjectIndices, DirtFilter);

            var LocationBuffer = stateData.LocationBuffer;



            for (int i0 = 0; i0 < RobotObjectIndices.Length; i0++)
            {
                var RobotIndex  = RobotObjectIndices[i0];
                var RobotObject = stateData.TraitBasedObjects[RobotIndex];



                for (int i1 = 0; i1 < DirtObjectIndices.Length; i1++)
                {
                    var DirtIndex  = DirtObjectIndices[i1];
                    var DirtObject = stateData.TraitBasedObjects[DirtIndex];

                    if (!(LocationBuffer[RobotObject.LocationIndex].Position == LocationBuffer[DirtObject.LocationIndex].Position))
                    {
                        continue;
                    }



                    var actionKey = new ActionKey(k_MaxArguments)
                    {
                        ActionGuid     = ActionGuid,
                        [k_RobotIndex] = RobotIndex,
                        [k_DirtIndex]  = DirtIndex,
                    };
                    argumentPermutations.Add(actionKey);
                }
            }
            RobotObjectIndices.Dispose();
            DirtObjectIndices.Dispose();
            RobotFilter.Dispose();
            DirtFilter.Dispose();
        }
コード例 #5
0
        void GenerateArgumentPermutations(StateData stateData, NativeList <ActionKey> argumentPermutations)
        {
            var MoverFilter = new NativeArray <ComponentType>(2, Allocator.Temp)
            {
                [0] = ComponentType.ReadWrite <Generated.AI.Planner.StateRepresentation.Moveable>(), [1] = ComponentType.ReadWrite <Unity.AI.Planner.DomainLanguage.TraitBased.Location>(),
            };
            var DestinationFilter = new NativeArray <ComponentType>(2, Allocator.Temp)
            {
                [0] = ComponentType.ReadWrite <Unity.AI.Planner.DomainLanguage.TraitBased.Location>(), [1] = ComponentType.Exclude <Generated.AI.Planner.StateRepresentation.Moveable>(),
            };
            var MoverObjectIndices = new NativeList <int>(2, Allocator.Temp);

            stateData.GetTraitBasedObjectIndices(MoverObjectIndices, MoverFilter);

            var DestinationObjectIndices = new NativeList <int>(2, Allocator.Temp);

            stateData.GetTraitBasedObjectIndices(DestinationObjectIndices, DestinationFilter);

            var LocationBuffer = stateData.LocationBuffer;



            for (int i0 = 0; i0 < MoverObjectIndices.Length; i0++)
            {
                var MoverIndex  = MoverObjectIndices[i0];
                var MoverObject = stateData.TraitBasedObjects[MoverIndex];



                for (int i1 = 0; i1 < DestinationObjectIndices.Length; i1++)
                {
                    var DestinationIndex  = DestinationObjectIndices[i1];
                    var DestinationObject = stateData.TraitBasedObjects[DestinationIndex];

                    if (!(LocationBuffer[MoverObject.LocationIndex].Position != LocationBuffer[DestinationObject.LocationIndex].Position))
                    {
                        continue;
                    }



                    var actionKey = new ActionKey(k_MaxArguments)
                    {
                        ActionGuid           = ActionGuid,
                        [k_MoverIndex]       = MoverIndex,
                        [k_DestinationIndex] = DestinationIndex,
                    };
                    argumentPermutations.Add(actionKey);
                }
            }
            MoverObjectIndices.Dispose();
            DestinationObjectIndices.Dispose();
            MoverFilter.Dispose();
            DestinationFilter.Dispose();
        }
コード例 #6
0
        void GenerateArgumentPermutations(StateData stateData, NativeList <ActionKey> argumentPermutations)
        {
            var NPCFilter = new NativeArray <ComponentType>(2, Allocator.Temp)
            {
                [0] = ComponentType.ReadWrite <Unity.AI.Planner.DomainLanguage.TraitBased.Location>(), [1] = ComponentType.ReadWrite <AI.Planner.Domains.Npc>(),
            };
            var WayPointFilter = new NativeArray <ComponentType>(2, Allocator.Temp)
            {
                [0] = ComponentType.ReadWrite <Unity.AI.Planner.DomainLanguage.TraitBased.Location>(), [1] = ComponentType.ReadWrite <AI.Planner.Domains.WayPoint>(),
            };
            var NPCObjectIndices = new NativeList <int>(2, Allocator.Temp);

            stateData.GetTraitBasedObjectIndices(NPCObjectIndices, NPCFilter);
            var WayPointObjectIndices = new NativeList <int>(2, Allocator.Temp);

            stateData.GetTraitBasedObjectIndices(WayPointObjectIndices, WayPointFilter);
            var LocationBuffer = stateData.LocationBuffer;

            for (int i0 = 0; i0 < NPCObjectIndices.Length; i0++)
            {
                var NPCIndex  = NPCObjectIndices[i0];
                var NPCObject = stateData.TraitBasedObjects[NPCIndex];


                for (int i1 = 0; i1 < WayPointObjectIndices.Length; i1++)
                {
                    var WayPointIndex  = WayPointObjectIndices[i1];
                    var WayPointObject = stateData.TraitBasedObjects[WayPointIndex];

                    if (!(LocationBuffer[NPCObject.LocationIndex].Position != LocationBuffer[WayPointObject.LocationIndex].Position))
                    {
                        continue;
                    }

                    var actionKey = new ActionKey(k_MaxArguments)
                    {
                        ActionGuid        = ActionGuid,
                        [k_NPCIndex]      = NPCIndex,
                        [k_WayPointIndex] = WayPointIndex,
                    };
                    argumentPermutations.Add(actionKey);
                }
            }
            NPCObjectIndices.Dispose();
            WayPointObjectIndices.Dispose();
            NPCFilter.Dispose();
            WayPointFilter.Dispose();
        }
コード例 #7
0
        public bool IsTerminal(StateData stateData)
        {
            var GameFilter = new NativeArray <ComponentType>(1, Allocator.Temp)
            {
                [0] = ComponentType.ReadWrite <Game>(),
            };
            var GameObjectIndices = new NativeList <int>(2, Allocator.Temp);

            stateData.GetTraitBasedObjectIndices(GameObjectIndices, GameFilter);
            var GameBuffer = stateData.GameBuffer;

            for (int i0 = 0; i0 < GameObjectIndices.Length; i0++)
            {
                var GameIndex  = GameObjectIndices[i0];
                var GameObject = stateData.TraitBasedObjects[GameIndex];


                if (!(GameBuffer[GameObject.GameIndex].MoveCount > 10))
                {
                    continue;
                }
                GameObjectIndices.Dispose();
                GameFilter.Dispose();
                return(true);
            }
            GameObjectIndices.Dispose();
            GameFilter.Dispose();

            return(false);
        }
コード例 #8
0
        public bool IsTerminal(StateData stateData)
        {
            var AgentFilter = new NativeArray <ComponentType>(1, Allocator.Temp)
            {
                [0] = ComponentType.ReadWrite <Agent>(),
            };
            var AgentObjectIndices = new NativeList <int>(2, Allocator.Temp);

            stateData.GetTraitBasedObjectIndices(AgentObjectIndices, AgentFilter);
            var AgentBuffer = stateData.AgentBuffer;

            for (int i0 = 0; i0 < AgentObjectIndices.Length; i0++)
            {
                var AgentIndex  = AgentObjectIndices[i0];
                var AgentObject = stateData.TraitBasedObjects[AgentIndex];


                if (!(AgentBuffer[AgentObject.AgentIndex].Health <= 0))
                {
                    continue;
                }
                AgentObjectIndices.Dispose();
                AgentFilter.Dispose();
                return(true);
            }
            AgentObjectIndices.Dispose();
            AgentFilter.Dispose();

            return(false);
        }
コード例 #9
0
        public bool IsTerminal(StateData stateData)
        {
            var BatteryFilter = new NativeArray <ComponentType>(1, Allocator.Temp)
            {
                [0] = ComponentType.ReadWrite <Robot>(),
            };
            var BatteryObjectIndices = new NativeList <int>(2, Allocator.Temp);

            stateData.GetTraitBasedObjectIndices(BatteryObjectIndices, BatteryFilter);
            var RobotBuffer = stateData.RobotBuffer;

            for (int i0 = 0; i0 < BatteryObjectIndices.Length; i0++)
            {
                var BatteryIndex  = BatteryObjectIndices[i0];
                var BatteryObject = stateData.TraitBasedObjects[BatteryIndex];


                if (!(RobotBuffer[BatteryObject.RobotIndex].Battery == 0))
                {
                    continue;
                }
                BatteryObjectIndices.Dispose();
                BatteryFilter.Dispose();
                return(true);
            }
            BatteryObjectIndices.Dispose();
            BatteryFilter.Dispose();

            return(false);
        }
コード例 #10
0
        void GenerateArgumentPermutations(StateData stateData, NativeList <ActionKey> argumentPermutations)
        {
            RobotObjectIndices.Clear();
            stateData.GetTraitBasedObjectIndices(RobotObjectIndices, RobotFilter);

            DirtObjectIndices.Clear();
            stateData.GetTraitBasedObjectIndices(DirtObjectIndices, DirtFilter);

            var LocationBuffer = stateData.LocationBuffer;



            for (int i0 = 0; i0 < RobotObjectIndices.Length; i0++)
            {
                var RobotIndex  = RobotObjectIndices[i0];
                var RobotObject = stateData.TraitBasedObjects[RobotIndex];



                for (int i1 = 0; i1 < DirtObjectIndices.Length; i1++)
                {
                    var DirtIndex  = DirtObjectIndices[i1];
                    var DirtObject = stateData.TraitBasedObjects[DirtIndex];

                    if (!(LocationBuffer[RobotObject.LocationIndex].Position == LocationBuffer[DirtObject.LocationIndex].Position))
                    {
                        continue;
                    }



                    var actionKey = new ActionKey(k_MaxArguments)
                    {
                        ActionGuid     = ActionGuid,
                        [k_RobotIndex] = RobotIndex,
                        [k_DirtIndex]  = DirtIndex,
                    };
                    argumentPermutations.Add(actionKey);
                }
            }
        }
コード例 #11
0
        void GenerateArgumentPermutations(StateData stateData, NativeList <ActionKey> argumentPermutations)
        {
            MoverObjectIndices.Clear();
            stateData.GetTraitBasedObjectIndices(MoverObjectIndices, MoverFilter);

            DestinationObjectIndices.Clear();
            stateData.GetTraitBasedObjectIndices(DestinationObjectIndices, DestinationFilter);

            var LocationBuffer = stateData.LocationBuffer;



            for (int i0 = 0; i0 < MoverObjectIndices.Length; i0++)
            {
                var MoverIndex  = MoverObjectIndices[i0];
                var MoverObject = stateData.TraitBasedObjects[MoverIndex];



                for (int i1 = 0; i1 < DestinationObjectIndices.Length; i1++)
                {
                    var DestinationIndex  = DestinationObjectIndices[i1];
                    var DestinationObject = stateData.TraitBasedObjects[DestinationIndex];

                    if (!(LocationBuffer[MoverObject.LocationIndex].Position != LocationBuffer[DestinationObject.LocationIndex].Position))
                    {
                        continue;
                    }



                    var actionKey = new ActionKey(k_MaxArguments)
                    {
                        ActionGuid           = ActionGuid,
                        [k_MoverIndex]       = MoverIndex,
                        [k_DestinationIndex] = DestinationIndex,
                    };
                    argumentPermutations.Add(actionKey);
                }
            }
        }
コード例 #12
0
        void GenerateArgumentPermutations(StateData stateData, NativeList <ActionKey> argumentPermutations)
        {
            var agentObjects = new NativeList <int>(4, Allocator.Temp);

            stateData.GetTraitBasedObjectIndices(agentObjects, s_AgentFilter);
            var roomObjects = new NativeList <int>(4, Allocator.Temp);

            stateData.GetTraitBasedObjectIndices(roomObjects, s_RoomFilter);

            var localizedBuffer = stateData.LocalizedBuffer;
            var objectIds       = stateData.TraitBasedObjectIds;

            // Get argument permutation and check preconditions
            for (var i = 0; i < roomObjects.Length; i++)
            {
                var roomIndex = roomObjects[i];

                for (var j = 0; j < agentObjects.Length; j++)
                {
                    var agentIndex  = agentObjects[j];
                    var agentObject = stateData.TraitBasedObjects[agentIndex];

                    if (localizedBuffer[agentObject.LocalizedIndex].Location == objectIds[roomIndex].Id)
                    {
                        continue;
                    }

                    argumentPermutations.Add(new ActionKey(k_MaxArguments)
                    {
                        ActionGuid     = ActionGuid,
                        [k_AgentIndex] = agentIndex,
                        [k_RoomIndex]  = roomIndex,
                    });
                }
            }

            agentObjects.Dispose();
            roomObjects.Dispose();
        }
コード例 #13
0
ファイル: SkipTurn.cs プロジェクト: duanma/ai-planner-samples
        void GenerateArgumentPermutations(StateData stateData, NativeList <ActionKey> argumentPermutations)
        {
            AgentObjectIndices.Clear();
            stateData.GetTraitBasedObjectIndices(AgentObjectIndices, AgentFilter);

            var AgentComparer = new global::AI.Tactics.PlayOrderComparer()
            {
                StateData = stateData
            };

            AgentObjectIndices.Sort(AgentComparer);
            var AgentBuffer = stateData.AgentBuffer;


            var validAgentCount = 0;

            for (int i0 = 0; i0 < AgentObjectIndices.Length; i0++)
            {
                var AgentIndex  = AgentObjectIndices[i0];
                var AgentObject = stateData.TraitBasedObjects[AgentIndex];

                if (!(AgentBuffer[AgentObject.AgentIndex].Safe == false))
                {
                    continue;
                }

                if (!(AgentBuffer[AgentObject.AgentIndex].Timeline < 1))
                {
                    continue;
                }


                var actionKey = new ActionKey(k_MaxArguments)
                {
                    ActionGuid     = ActionGuid,
                    [k_AgentIndex] = AgentIndex,
                };
                argumentPermutations.Add(actionKey);

                validAgentCount++;
                if (validAgentCount >= 1)
                {
                    break;
                }
            }
        }
コード例 #14
0
        public void TestObjectFiltering500Rooms()
        {
            StateData stateData = default;
            var       objects   = new NativeList <int>(Allocator.Temp);
            var       types     = new NativeArray <ComponentType>(2, Allocator.TempJob)
            {
                [0] = ComponentType.ReadWrite <Colored>(), [1] = ComponentType.ReadWrite <Lockable>()
            };

            Measure.Method(() =>
            {
                stateData.GetTraitBasedObjectIndices(objects, types);
            }).SetUp(() =>
            {
                stateData = m_StateManager.CopyStateData(m_LargeStateData);
                objects.Clear();
            }).WarmupCount(1).MeasurementCount(30).IterationsPerMeasurement(1).Run();

            types.Dispose();
            objects.Dispose();

            PerformanceUtility.AssertRange(0.11, 0.19);
        }
コード例 #15
0
        void GenerateArgumentPermutations(StateData stateData, NativeList <ActionKey> argumentPermutations)
        {
            AgentObjectIndices.Clear();
            stateData.GetTraitBasedObjectIndices(AgentObjectIndices, AgentFilter);

            var AgentComparer = new global::AI.Tactics.PlayOrderComparer()
            {
                StateData = stateData
            };

            AgentObjectIndices.Sort(AgentComparer);
            CoverObjectIndices.Clear();
            stateData.GetTraitBasedObjectIndices(CoverObjectIndices, CoverFilter);

            var CoverBuffer    = stateData.CoverBuffer;
            var LocationBuffer = stateData.LocationBuffer;
            var AgentBuffer    = stateData.AgentBuffer;


            var validAgentCount = 0;

            for (int i0 = 0; i0 < AgentObjectIndices.Length; i0++)
            {
                var AgentIndex  = AgentObjectIndices[i0];
                var AgentObject = stateData.TraitBasedObjects[AgentIndex];



                if (!(AgentBuffer[AgentObject.AgentIndex].Safe == false))
                {
                    continue;
                }



                for (int i1 = 0; i1 < CoverObjectIndices.Length; i1++)
                {
                    var CoverIndex  = CoverObjectIndices[i1];
                    var CoverObject = stateData.TraitBasedObjects[CoverIndex];

                    if (!(CoverBuffer[CoverObject.CoverIndex].SpotTaken == false))
                    {
                        continue;
                    }

                    if (!(LocationBuffer[AgentObject.LocationIndex].Position != LocationBuffer[CoverObject.LocationIndex].Position))
                    {
                        continue;
                    }



                    var actionKey = new ActionKey(k_MaxArguments)
                    {
                        ActionGuid     = ActionGuid,
                        [k_AgentIndex] = AgentIndex,
                        [k_CoverIndex] = CoverIndex,
                    };
                    argumentPermutations.Add(actionKey);
                }

                validAgentCount++;
                if (validAgentCount >= 1)
                {
                    break;
                }
            }
        }
コード例 #16
0
        void GenerateArgumentPermutations(StateData stateData, NativeList <ActionKey> argumentPermutations)
        {
            var GameFilter = new NativeArray <ComponentType>(1, Allocator.Temp)
            {
                [0] = ComponentType.ReadWrite <AI.Planner.Domains.Game>(),
            };
            var SourceFilter = new NativeArray <ComponentType>(3, Allocator.Temp)
            {
                [0] = ComponentType.ReadWrite <AI.Planner.Domains.Coordinate>(), [1] = ComponentType.ReadWrite <AI.Planner.Domains.Cell>(), [2] = ComponentType.Exclude <AI.Planner.Domains.Blocker>(),
            };
            var TargetFilter = new NativeArray <ComponentType>(3, Allocator.Temp)
            {
                [0] = ComponentType.ReadWrite <AI.Planner.Domains.Coordinate>(), [1] = ComponentType.ReadWrite <AI.Planner.Domains.Cell>(), [2] = ComponentType.Exclude <AI.Planner.Domains.Blocker>(),
            };
            var GameObjectIndices = new NativeList <int>(2, Allocator.Temp);

            stateData.GetTraitBasedObjectIndices(GameObjectIndices, GameFilter);
            var SourceObjectIndices = new NativeList <int>(2, Allocator.Temp);

            stateData.GetTraitBasedObjectIndices(SourceObjectIndices, SourceFilter);
            var TargetObjectIndices = new NativeList <int>(2, Allocator.Temp);

            stateData.GetTraitBasedObjectIndices(TargetObjectIndices, TargetFilter);
            var CellBuffer = stateData.CellBuffer;

            for (int i0 = 0; i0 < GameObjectIndices.Length; i0++)
            {
                var GameIndex  = GameObjectIndices[i0];
                var GameObject = stateData.TraitBasedObjects[GameIndex];



                for (int i1 = 0; i1 < SourceObjectIndices.Length; i1++)
                {
                    var SourceIndex  = SourceObjectIndices[i1];
                    var SourceObject = stateData.TraitBasedObjects[SourceIndex];


                    if (!(CellBuffer[SourceObject.CellIndex].Type != CellType.None))
                    {
                        continue;
                    }


                    for (int i2 = 0; i2 < TargetObjectIndices.Length; i2++)
                    {
                        var TargetIndex  = TargetObjectIndices[i2];
                        var TargetObject = stateData.TraitBasedObjects[TargetIndex];

                        if (!(CellBuffer[SourceObject.CellIndex].Right == stateData.GetTraitBasedObjectId(TargetIndex)))
                        {
                            continue;
                        }


                        if (!(CellBuffer[TargetObject.CellIndex].Type != CellType.None))
                        {
                            continue;
                        }

                        var actionKey = new ActionKey(k_MaxArguments)
                        {
                            ActionGuid      = ActionGuid,
                            [k_GameIndex]   = GameIndex,
                            [k_SourceIndex] = SourceIndex,
                            [k_TargetIndex] = TargetIndex,
                        };
                        argumentPermutations.Add(actionKey);
                    }
                }
            }
            GameObjectIndices.Dispose();
            SourceObjectIndices.Dispose();
            TargetObjectIndices.Dispose();
            GameFilter.Dispose();
            SourceFilter.Dispose();
            TargetFilter.Dispose();
        }
コード例 #17
0
        void GenerateArgumentPermutations(StateData stateData, NativeList <ActionKey> argumentPermutations)
        {
            var agentObjects = new NativeList <int>(4, Allocator.Temp);

            stateData.GetTraitBasedObjectIndices(agentObjects, s_AgentFilter);
            var keyObjects = new NativeList <int>(4, Allocator.Temp);

            stateData.GetTraitBasedObjectIndices(keyObjects, s_KeyFilter);
            var roomObjects = new NativeList <int>(4, Allocator.Temp);

            stateData.GetTraitBasedObjectIndices(roomObjects, s_RoomFilter);

            if (roomObjects.Length <= 0)
            {
                return;
            }

            var traitBasedObjectIds = stateData.TraitBasedObjectIds;
            var carriableBuffer     = stateData.CarriableBuffer;
            var carrierBuffer       = stateData.CarrierBuffer;
            var localizedBuffer     = stateData.LocalizedBuffer;

            var firstRoom     = traitBasedObjectIds[roomObjects[0]].Id;
            var agentKeyIndex = -1;

            for (var i = 0; i < keyObjects.Length; i++)
            {
                var keyIndex  = keyObjects[i];
                var keyObject = stateData.TraitBasedObjects[keyIndex];

                if (carriableBuffer[keyObject.CarriableIndex].Carrier != ObjectId.None)
                {
                    continue;
                }

                for (var j = 0; j < agentObjects.Length; j++)
                {
                    var agentIndex  = agentObjects[j];
                    var agentObject = stateData.TraitBasedObjects[agentIndex];

                    if (carrierBuffer[agentObject.CarrierIndex].CarriedObject == traitBasedObjectIds[keyIndex].Id)
                    {
                        agentKeyIndex = keyIndex;
                        break;
                    }
                }

                if (keyIndex >= 0)
                {
                    break;
                }
            }

            // Get argument permutation and check preconditions
            for (var i = 0; i < keyObjects.Length; i++)
            {
                var keyIndex  = keyObjects[i];
                var keyObject = stateData.TraitBasedObjects[keyIndex];

                if (carriableBuffer[keyObject.CarriableIndex].Carrier != ObjectId.None)
                {
                    continue;
                }

                for (var j = 0; j < agentObjects.Length; j++)
                {
                    var agentIndex  = agentObjects[j];
                    var agentObject = stateData.TraitBasedObjects[agentIndex];

                    if (carrierBuffer[agentObject.CarrierIndex].CarriedObject == traitBasedObjectIds[keyIndex].Id)
                    {
                        continue;
                    }

                    if (localizedBuffer[agentObject.LocalizedIndex].Location != firstRoom)
                    {
                        continue;
                    }

                    argumentPermutations.Add(new ActionKey(k_MaxArguments)
                    {
                        ActionGuid        = ActionGuid,
                        [k_KeyIndex]      = keyIndex,
                        [k_AgentIndex]    = agentIndex,
                        [k_AgentKeyIndex] = agentKeyIndex
                    });
                }
            }

            agentObjects.Dispose();
            keyObjects.Dispose();
            roomObjects.Dispose();
        }
コード例 #18
0
        void GenerateArgumentPermutations(StateData stateData, NativeList <ActionKey> argumentPermutations)
        {
            var CharacterFilter = new NativeArray <ComponentType>(2, Allocator.Temp)
            {
                [0] = ComponentType.ReadWrite <AI.Planner.Domains.Carrier>(), [1] = ComponentType.ReadWrite <AI.Planner.Domains.Character>(),
            };
            var ItemFilter = new NativeArray <ComponentType>(3, Allocator.Temp)
            {
                [0] = ComponentType.ReadWrite <AI.Planner.Domains.Carriable>(), [1] = ComponentType.ReadWrite <AI.Planner.Domains.Position>(), [2] = ComponentType.ReadWrite <AI.Planner.Domains.Item>(),
            };
            var CharacterObjectIndices = new NativeList <int>(2, Allocator.Temp);

            stateData.GetTraitBasedObjectIndices(CharacterObjectIndices, CharacterFilter);
            var ItemObjectIndices = new NativeList <int>(2, Allocator.Temp);

            stateData.GetTraitBasedObjectIndices(ItemObjectIndices, ItemFilter);
            var CharacterBuffer = stateData.CharacterBuffer;
            var CarriableBuffer = stateData.CarriableBuffer;
            var CarrierBuffer   = stateData.CarrierBuffer;
            var PositionBuffer  = stateData.PositionBuffer;

            for (int i0 = 0; i0 < CharacterObjectIndices.Length; i0++)
            {
                var CharacterIndex  = CharacterObjectIndices[i0];
                var CharacterObject = stateData.TraitBasedObjects[CharacterIndex];



                if (!(CarrierBuffer[CharacterObject.CarrierIndex].Carried == TraitBasedObjectId.None))
                {
                    continue;
                }

                for (int i1 = 0; i1 < ItemObjectIndices.Length; i1++)
                {
                    var ItemIndex  = ItemObjectIndices[i1];
                    var ItemObject = stateData.TraitBasedObjects[ItemIndex];

                    if (!(CharacterBuffer[CharacterObject.CharacterIndex].Waypoint == PositionBuffer[ItemObject.PositionIndex].Waypoint))
                    {
                        continue;
                    }

                    if (!(CarriableBuffer[ItemObject.CarriableIndex].CarriedBy == TraitBasedObjectId.None))
                    {
                        continue;
                    }


                    var actionKey = new ActionKey(k_MaxArguments)
                    {
                        ActionGuid         = ActionGuid,
                        [k_CharacterIndex] = CharacterIndex,
                        [k_ItemIndex]      = ItemIndex,
                    };
                    argumentPermutations.Add(actionKey);
                }
            }
            CharacterObjectIndices.Dispose();
            ItemObjectIndices.Dispose();
            CharacterFilter.Dispose();
            ItemFilter.Dispose();
        }
コード例 #19
0
        void GenerateArgumentPermutations(StateData stateData, NativeList <ActionKey> argumentPermutations)
        {
            CharacterObjectIndices.Clear();
            stateData.GetTraitBasedObjectIndices(CharacterObjectIndices, CharacterFilter);

            ToObjectIndices.Clear();
            stateData.GetTraitBasedObjectIndices(ToObjectIndices, ToFilter);

            FromObjectIndices.Clear();
            stateData.GetTraitBasedObjectIndices(FromObjectIndices, FromFilter);

            var CharacterBuffer = stateData.CharacterBuffer;
            var WaypointBuffer  = stateData.WaypointBuffer;
            var CarrierBuffer   = stateData.CarrierBuffer;



            for (int i0 = 0; i0 < CharacterObjectIndices.Length; i0++)
            {
                var CharacterIndex  = CharacterObjectIndices[i0];
                var CharacterObject = stateData.TraitBasedObjects[CharacterIndex];



                if (!(CarrierBuffer[CharacterObject.CarrierIndex].Carried != TraitBasedObjectId.None))
                {
                    continue;
                }



                for (int i1 = 0; i1 < ToObjectIndices.Length; i1++)
                {
                    var ToIndex  = ToObjectIndices[i1];
                    var ToObject = stateData.TraitBasedObjects[ToIndex];


                    if (!(WaypointBuffer[ToObject.WaypointIndex].Occupied == false))
                    {
                        continue;
                    }



                    for (int i2 = 0; i2 < FromObjectIndices.Length; i2++)
                    {
                        var FromIndex  = FromObjectIndices[i2];
                        var FromObject = stateData.TraitBasedObjects[FromIndex];

                        if (!(CharacterBuffer[CharacterObject.CharacterIndex].Waypoint == stateData.GetTraitBasedObjectId(FromIndex)))
                        {
                            continue;
                        }


                        if (!(WaypointBuffer[ToObject.WaypointIndex].Right == stateData.GetTraitBasedObjectId(FromIndex)))
                        {
                            continue;
                        }



                        var actionKey = new ActionKey(k_MaxArguments)
                        {
                            ActionGuid         = ActionGuid,
                            [k_CharacterIndex] = CharacterIndex,
                            [k_ToIndex]        = ToIndex,
                            [k_FromIndex]      = FromIndex,
                        };
                        argumentPermutations.Add(actionKey);
                    }
                }
            }
        }
コード例 #20
0
        void GenerateArgumentPermutations(StateData stateData, NativeList <ActionKey> argumentPermutations)
        {
            var AgentFilter = new NativeArray <ComponentType>(2, Allocator.Temp)
            {
                [0] = ComponentType.ReadWrite <Generated.AI.Planner.StateRepresentation.Agent>(), [1] = ComponentType.ReadWrite <Unity.AI.Planner.DomainLanguage.TraitBased.Location>(),
            };
            var TargetFilter = new NativeArray <ComponentType>(2, Allocator.Temp)
            {
                [0] = ComponentType.ReadWrite <Unity.AI.Planner.DomainLanguage.TraitBased.Location>(), [1] = ComponentType.ReadWrite <Generated.AI.Planner.StateRepresentation.Target>(),
            };
            var AgentObjectIndices = new NativeList <int>(2, Allocator.Temp);

            stateData.GetTraitBasedObjectIndices(AgentObjectIndices, AgentFilter);

            var TargetObjectIndices = new NativeList <int>(2, Allocator.Temp);

            stateData.GetTraitBasedObjectIndices(TargetObjectIndices, TargetFilter);

            var AgentBuffer  = stateData.AgentBuffer;
            var TargetBuffer = stateData.TargetBuffer;



            for (int i0 = 0; i0 < AgentObjectIndices.Length; i0++)
            {
                var AgentIndex  = AgentObjectIndices[i0];
                var AgentObject = stateData.TraitBasedObjects[AgentIndex];


                if (!(AgentBuffer[AgentObject.AgentIndex].Navigating == false))
                {
                    continue;
                }



                for (int i1 = 0; i1 < TargetObjectIndices.Length; i1++)
                {
                    var TargetIndex  = TargetObjectIndices[i1];
                    var TargetObject = stateData.TraitBasedObjects[TargetIndex];

                    if (!(AgentBuffer[AgentObject.AgentIndex].UniqueId != TargetBuffer[TargetObject.TargetIndex].UniqueId))
                    {
                        continue;
                    }



                    var actionKey = new ActionKey(k_MaxArguments)
                    {
                        ActionGuid      = ActionGuid,
                        [k_AgentIndex]  = AgentIndex,
                        [k_TargetIndex] = TargetIndex,
                    };
                    argumentPermutations.Add(actionKey);
                }
            }
            AgentObjectIndices.Dispose();
            TargetObjectIndices.Dispose();
            AgentFilter.Dispose();
            TargetFilter.Dispose();
        }
コード例 #21
0
        void GenerateArgumentPermutations(StateData stateData, NativeList <ActionKey> argumentPermutations)
        {
            var AgentFilter = new NativeArray <ComponentType>(2, Allocator.Temp)
            {
                [0] = ComponentType.ReadWrite <Generated.AI.Planner.StateRepresentation.Agent>(), [1] = ComponentType.ReadWrite <Unity.AI.Planner.DomainLanguage.TraitBased.Location>(),
            };
            var CollectibleFilter = new NativeArray <ComponentType>(2, Allocator.Temp)
            {
                [0] = ComponentType.ReadWrite <Unity.AI.Planner.DomainLanguage.TraitBased.Location>(), [1] = ComponentType.ReadWrite <Generated.AI.Planner.StateRepresentation.Collectible>(),
            };
            var AgentObjectIndices = new NativeList <int>(2, Allocator.Temp);

            stateData.GetTraitBasedObjectIndices(AgentObjectIndices, AgentFilter);

            var CollectibleObjectIndices = new NativeList <int>(2, Allocator.Temp);

            stateData.GetTraitBasedObjectIndices(CollectibleObjectIndices, CollectibleFilter);

            var AgentBuffer       = stateData.AgentBuffer;
            var CollectibleBuffer = stateData.CollectibleBuffer;



            for (int i0 = 0; i0 < AgentObjectIndices.Length; i0++)
            {
                var AgentIndex  = AgentObjectIndices[i0];
                var AgentObject = stateData.TraitBasedObjects[AgentIndex];

                if (!(AgentBuffer[AgentObject.AgentIndex].Ammo < 50))
                {
                    continue;
                }



                for (int i1 = 0; i1 < CollectibleObjectIndices.Length; i1++)
                {
                    var CollectibleIndex  = CollectibleObjectIndices[i1];
                    var CollectibleObject = stateData.TraitBasedObjects[CollectibleIndex];


                    if (!(CollectibleBuffer[CollectibleObject.CollectibleIndex].Provides == Consumable.Health))
                    {
                        continue;
                    }

                    if (!(CollectibleBuffer[CollectibleObject.CollectibleIndex].Active == true))
                    {
                        continue;
                    }



                    var actionKey = new ActionKey(k_MaxArguments)
                    {
                        ActionGuid           = ActionGuid,
                        [k_AgentIndex]       = AgentIndex,
                        [k_CollectibleIndex] = CollectibleIndex,
                    };
                    argumentPermutations.Add(actionKey);
                }
            }
            AgentObjectIndices.Dispose();
            CollectibleObjectIndices.Dispose();
            AgentFilter.Dispose();
            CollectibleFilter.Dispose();
        }
コード例 #22
0
        void GenerateArgumentPermutations(StateData stateData, NativeList <ActionKey> argumentPermutations)
        {
            AgentObjectIndices.Clear();
            stateData.GetTraitBasedObjectIndices(AgentObjectIndices, AgentFilter);

            var AgentComparer = new global::AI.Tactics.PlayOrderComparer()
            {
                StateData = stateData
            };

            AgentObjectIndices.Sort(AgentComparer);
            ItemObjectIndices.Clear();
            stateData.GetTraitBasedObjectIndices(ItemObjectIndices, ItemFilter);

            var AgentBuffer = stateData.AgentBuffer;
            var ItemBuffer  = stateData.ItemBuffer;


            var validAgentCount = 0;

            for (int i0 = 0; i0 < AgentObjectIndices.Length; i0++)
            {
                var AgentIndex  = AgentObjectIndices[i0];
                var AgentObject = stateData.TraitBasedObjects[AgentIndex];

                if (!(AgentBuffer[AgentObject.AgentIndex].HasWeapon == false))
                {
                    continue;
                }



                for (int i1 = 0; i1 < ItemObjectIndices.Length; i1++)
                {
                    var ItemIndex  = ItemObjectIndices[i1];
                    var ItemObject = stateData.TraitBasedObjects[ItemIndex];


                    if (!(ItemBuffer[ItemObject.ItemIndex].CarriedBy == TraitBasedObjectId.None))
                    {
                        continue;
                    }



                    var actionKey = new ActionKey(k_MaxArguments)
                    {
                        ActionGuid     = ActionGuid,
                        [k_AgentIndex] = AgentIndex,
                        [k_ItemIndex]  = ItemIndex,
                    };
                    argumentPermutations.Add(actionKey);
                }

                validAgentCount++;
                if (validAgentCount >= 1)
                {
                    break;
                }
            }
        }
コード例 #23
0
        void GenerateArgumentPermutations(StateData stateData, NativeList <ActionKey> argumentPermutations)
        {
            CharacterObjectIndices.Clear();
            stateData.GetTraitBasedObjectIndices(CharacterObjectIndices, CharacterFilter);

            ToObjectIndices.Clear();
            stateData.GetTraitBasedObjectIndices(ToObjectIndices, ToFilter);

            FromObjectIndices.Clear();
            stateData.GetTraitBasedObjectIndices(FromObjectIndices, FromFilter);

            ActivationBlueObjectIndices.Clear();
            stateData.GetTraitBasedObjectIndices(ActivationBlueObjectIndices, ActivationBlueFilter);

            ActivationPinkObjectIndices.Clear();
            stateData.GetTraitBasedObjectIndices(ActivationPinkObjectIndices, ActivationPinkFilter);

            var WaypointBuffer         = stateData.WaypointBuffer;
            var CharacterBuffer        = stateData.CharacterBuffer;
            var ActivationSwitchBuffer = stateData.ActivationSwitchBuffer;



            for (int i0 = 0; i0 < CharacterObjectIndices.Length; i0++)
            {
                var CharacterIndex  = CharacterObjectIndices[i0];
                var CharacterObject = stateData.TraitBasedObjects[CharacterIndex];



                for (int i1 = 0; i1 < ToObjectIndices.Length; i1++)
                {
                    var ToIndex  = ToObjectIndices[i1];
                    var ToObject = stateData.TraitBasedObjects[ToIndex];

                    if (!(WaypointBuffer[ToObject.WaypointIndex].Occupied == false))
                    {
                        continue;
                    }

                    if (!(WaypointBuffer[ToObject.WaypointIndex].Down == CharacterBuffer[CharacterObject.CharacterIndex].Waypoint))
                    {
                        continue;
                    }



                    for (int i2 = 0; i2 < FromObjectIndices.Length; i2++)
                    {
                        var FromIndex  = FromObjectIndices[i2];
                        var FromObject = stateData.TraitBasedObjects[FromIndex];



                        if (!(CharacterBuffer[CharacterObject.CharacterIndex].Waypoint == stateData.GetTraitBasedObjectId(FromIndex)))
                        {
                            continue;
                        }



                        for (int i3 = 0; i3 < ActivationBlueObjectIndices.Length; i3++)
                        {
                            var ActivationBlueIndex  = ActivationBlueObjectIndices[i3];
                            var ActivationBlueObject = stateData.TraitBasedObjects[ActivationBlueIndex];



                            if (!(WaypointBuffer[ActivationBlueObject.WaypointIndex].Occupied == true))
                            {
                                continue;
                            }


                            if (!(ActivationSwitchBuffer[ActivationBlueObject.ActivationSwitchIndex].Type == ActivationType.Blue))
                            {
                                continue;
                            }



                            for (int i4 = 0; i4 < ActivationPinkObjectIndices.Length; i4++)
                            {
                                var ActivationPinkIndex  = ActivationPinkObjectIndices[i4];
                                var ActivationPinkObject = stateData.TraitBasedObjects[ActivationPinkIndex];



                                if (!(WaypointBuffer[ActivationPinkObject.WaypointIndex].Occupied == true))
                                {
                                    continue;
                                }


                                if (!(ActivationSwitchBuffer[ActivationPinkObject.ActivationSwitchIndex].Type == ActivationType.Pink))
                                {
                                    continue;
                                }



                                var actionKey = new ActionKey(k_MaxArguments)
                                {
                                    ActionGuid              = ActionGuid,
                                    [k_CharacterIndex]      = CharacterIndex,
                                    [k_ToIndex]             = ToIndex,
                                    [k_FromIndex]           = FromIndex,
                                    [k_ActivationBlueIndex] = ActivationBlueIndex,
                                    [k_ActivationPinkIndex] = ActivationPinkIndex,
                                };
                                argumentPermutations.Add(actionKey);
                            }
                        }
                    }
                }
            }
        }
コード例 #24
0
        void GenerateArgumentPermutations(StateData stateData, NativeList <ActionKey> argumentPermutations)
        {
            GameObjectIndices.Clear();
            stateData.GetTraitBasedObjectIndices(GameObjectIndices, GameFilter);

            SourceObjectIndices.Clear();
            stateData.GetTraitBasedObjectIndices(SourceObjectIndices, SourceFilter);

            TargetObjectIndices.Clear();
            stateData.GetTraitBasedObjectIndices(TargetObjectIndices, TargetFilter);

            var CellBuffer = stateData.CellBuffer;



            for (int i0 = 0; i0 < GameObjectIndices.Length; i0++)
            {
                var GameIndex  = GameObjectIndices[i0];
                var GameObject = stateData.TraitBasedObjects[GameIndex];



                for (int i1 = 0; i1 < SourceObjectIndices.Length; i1++)
                {
                    var SourceIndex  = SourceObjectIndices[i1];
                    var SourceObject = stateData.TraitBasedObjects[SourceIndex];


                    if (!(CellBuffer[SourceObject.CellIndex].Type != CellType.None))
                    {
                        continue;
                    }



                    for (int i2 = 0; i2 < TargetObjectIndices.Length; i2++)
                    {
                        var TargetIndex  = TargetObjectIndices[i2];
                        var TargetObject = stateData.TraitBasedObjects[TargetIndex];

                        if (!(CellBuffer[SourceObject.CellIndex].Right == stateData.GetTraitBasedObjectId(TargetIndex)))
                        {
                            continue;
                        }


                        if (!(CellBuffer[TargetObject.CellIndex].Type != CellType.None))
                        {
                            continue;
                        }



                        var actionKey = new ActionKey(k_MaxArguments)
                        {
                            ActionGuid      = ActionGuid,
                            [k_GameIndex]   = GameIndex,
                            [k_SourceIndex] = SourceIndex,
                            [k_TargetIndex] = TargetIndex,
                        };
                        argumentPermutations.Add(actionKey);
                    }
                }
            }
        }
コード例 #25
0
        void GenerateArgumentPermutations(StateData stateData, NativeList <ActionKey> argumentPermutations)
        {
            var traitBasedObjects = stateData.TraitBasedObjects;
            var agentObjects      = new NativeList <int>(4, Allocator.Temp);

            stateData.GetTraitBasedObjectIndices(agentObjects, s_AgentFilter);
            var roomObjects = new NativeList <int>(4, Allocator.Temp);

            stateData.GetTraitBasedObjectIndices(roomObjects, s_RoomFilter);
            var keyObjects = new NativeList <int>(4, Allocator.Temp);

            stateData.GetTraitBasedObjectIndices(keyObjects, s_KeyFilter);

            var objectIds       = stateData.TraitBasedObjectIds;
            var lockableBuffer  = stateData.LockableBuffer;
            var localizedBuffer = stateData.LocalizedBuffer;
            var carrierBuffer   = stateData.CarrierBuffer;
            var coloredBuffer   = stateData.ColoredBuffer;

            // Get argument permutation and check preconditions
            for (var i = 0; i < roomObjects.Length; i++)
            {
                var roomIndex  = roomObjects[i];
                var roomObject = traitBasedObjects[roomIndex];

                if (!lockableBuffer[roomObject.LockableIndex].Locked)
                {
                    continue;
                }

                for (var j = 0; j < agentObjects.Length; j++)
                {
                    var agentIndex  = agentObjects[j];
                    var agentObject = traitBasedObjects[agentIndex];

                    if (localizedBuffer[agentObject.LocalizedIndex].Location != objectIds[roomIndex].Id)
                    {
                        continue;
                    }

                    for (var k = 0; k < keyObjects.Length; k++)
                    {
                        var keyIndex  = keyObjects[k];
                        var keyObject = traitBasedObjects[keyIndex];

                        if (carrierBuffer[agentObject.CarrierIndex].CarriedObject != objectIds[keyIndex].Id)
                        {
                            continue;
                        }

                        if (!coloredBuffer[roomObject.ColoredIndex].Color.Equals(coloredBuffer[keyObject.ColoredIndex].Color))
                        {
                            continue;
                        }

                        argumentPermutations.Add(new ActionKey(k_MaxArguments)
                        {
                            ActionGuid     = ActionGuid,
                            [k_AgentIndex] = agentIndex,
                            [k_RoomIndex]  = roomIndex,
                        });
                    }
                }
            }

            agentObjects.Dispose();
            roomObjects.Dispose();
            keyObjects.Dispose();
        }
コード例 #26
0
        void GenerateArgumentPermutations(StateData stateData, NativeList <ActionKey> argumentPermutations)
        {
            var CharacterFilter = new NativeArray <ComponentType>(1, Allocator.Temp)
            {
                [0] = ComponentType.ReadWrite <Generated.AI.Planner.StateRepresentation.Character>(),
            };
            var ToFilter = new NativeArray <ComponentType>(3, Allocator.Temp)
            {
                [0] = ComponentType.ReadWrite <Generated.AI.Planner.StateRepresentation.Waypoint>(), [1] = ComponentType.Exclude <Generated.AI.Planner.StateRepresentation.ActivationLock>(), [2] = ComponentType.Exclude <Generated.AI.Planner.StateRepresentation.KeyLock>(),
            };
            var FromFilter = new NativeArray <ComponentType>(1, Allocator.Temp)
            {
                [0] = ComponentType.ReadWrite <Generated.AI.Planner.StateRepresentation.Waypoint>(),
            };
            var CharacterObjectIndices = new NativeList <int>(2, Allocator.Temp);

            stateData.GetTraitBasedObjectIndices(CharacterObjectIndices, CharacterFilter);

            var ToObjectIndices = new NativeList <int>(2, Allocator.Temp);

            stateData.GetTraitBasedObjectIndices(ToObjectIndices, ToFilter);

            var FromObjectIndices = new NativeList <int>(2, Allocator.Temp);

            stateData.GetTraitBasedObjectIndices(FromObjectIndices, FromFilter);

            var WaypointBuffer  = stateData.WaypointBuffer;
            var CharacterBuffer = stateData.CharacterBuffer;



            for (int i0 = 0; i0 < CharacterObjectIndices.Length; i0++)
            {
                var CharacterIndex  = CharacterObjectIndices[i0];
                var CharacterObject = stateData.TraitBasedObjects[CharacterIndex];



                for (int i1 = 0; i1 < ToObjectIndices.Length; i1++)
                {
                    var ToIndex  = ToObjectIndices[i1];
                    var ToObject = stateData.TraitBasedObjects[ToIndex];

                    if (!(WaypointBuffer[ToObject.WaypointIndex].Occupied == false))
                    {
                        continue;
                    }

                    if (!(WaypointBuffer[ToObject.WaypointIndex].Left == CharacterBuffer[CharacterObject.CharacterIndex].Waypoint))
                    {
                        continue;
                    }



                    for (int i2 = 0; i2 < FromObjectIndices.Length; i2++)
                    {
                        var FromIndex  = FromObjectIndices[i2];
                        var FromObject = stateData.TraitBasedObjects[FromIndex];



                        if (!(CharacterBuffer[CharacterObject.CharacterIndex].Waypoint == stateData.GetTraitBasedObjectId(FromIndex)))
                        {
                            continue;
                        }



                        var actionKey = new ActionKey(k_MaxArguments)
                        {
                            ActionGuid         = ActionGuid,
                            [k_CharacterIndex] = CharacterIndex,
                            [k_ToIndex]        = ToIndex,
                            [k_FromIndex]      = FromIndex,
                        };
                        argumentPermutations.Add(actionKey);
                    }
                }
            }
            CharacterObjectIndices.Dispose();
            ToObjectIndices.Dispose();
            FromObjectIndices.Dispose();
            CharacterFilter.Dispose();
            ToFilter.Dispose();
            FromFilter.Dispose();
        }
コード例 #27
0
        public bool IsTerminal(StateData stateData)
        {
            var Character1Filter = new NativeArray <ComponentType>(1, Allocator.Temp)
            {
                [0] = ComponentType.ReadWrite <Character>(),
            };
            var Character1ObjectIndices = new NativeList <int>(2, Allocator.Temp);

            stateData.GetTraitBasedObjectIndices(Character1ObjectIndices, Character1Filter);
            var Character2Filter = new NativeArray <ComponentType>(1, Allocator.Temp)
            {
                [0] = ComponentType.ReadWrite <Character>(),
            };
            var Character2ObjectIndices = new NativeList <int>(2, Allocator.Temp);

            stateData.GetTraitBasedObjectIndices(Character2ObjectIndices, Character2Filter);
            var Character3Filter = new NativeArray <ComponentType>(1, Allocator.Temp)
            {
                [0] = ComponentType.ReadWrite <Character>(),
            };
            var Character3ObjectIndices = new NativeList <int>(2, Allocator.Temp);

            stateData.GetTraitBasedObjectIndices(Character3ObjectIndices, Character3Filter);
            var Waypoint1Filter = new NativeArray <ComponentType>(2, Allocator.Temp)
            {
                [0] = ComponentType.ReadWrite <Waypoint>(), [1] = ComponentType.ReadWrite <EscapePoint>(),
            };
            var Waypoint1ObjectIndices = new NativeList <int>(2, Allocator.Temp);

            stateData.GetTraitBasedObjectIndices(Waypoint1ObjectIndices, Waypoint1Filter);
            var Waypoint2Filter = new NativeArray <ComponentType>(2, Allocator.Temp)
            {
                [0] = ComponentType.ReadWrite <Waypoint>(), [1] = ComponentType.ReadWrite <EscapePoint>(),
            };
            var Waypoint2ObjectIndices = new NativeList <int>(2, Allocator.Temp);

            stateData.GetTraitBasedObjectIndices(Waypoint2ObjectIndices, Waypoint2Filter);
            var Waypoint3Filter = new NativeArray <ComponentType>(2, Allocator.Temp)
            {
                [0] = ComponentType.ReadWrite <Waypoint>(), [1] = ComponentType.ReadWrite <EscapePoint>(),
            };
            var Waypoint3ObjectIndices = new NativeList <int>(2, Allocator.Temp);

            stateData.GetTraitBasedObjectIndices(Waypoint3ObjectIndices, Waypoint3Filter);
            var CharacterBuffer = stateData.CharacterBuffer;

            for (int i0 = 0; i0 < Character1ObjectIndices.Length; i0++)
            {
                var Character1Index  = Character1ObjectIndices[i0];
                var Character1Object = stateData.TraitBasedObjects[Character1Index];



                for (int i1 = 0; i1 < Character2ObjectIndices.Length; i1++)
                {
                    var Character2Index  = Character2ObjectIndices[i1];
                    var Character2Object = stateData.TraitBasedObjects[Character2Index];


                    if (!(stateData.GetTraitBasedObjectId(Character1Index) != stateData.GetTraitBasedObjectId(Character2Index)))
                    {
                        continue;
                    }



                    for (int i2 = 0; i2 < Character3ObjectIndices.Length; i2++)
                    {
                        var Character3Index  = Character3ObjectIndices[i2];
                        var Character3Object = stateData.TraitBasedObjects[Character3Index];



                        if (!(stateData.GetTraitBasedObjectId(Character2Index) != stateData.GetTraitBasedObjectId(Character3Index)))
                        {
                            continue;
                        }

                        if (!(stateData.GetTraitBasedObjectId(Character1Index) != stateData.GetTraitBasedObjectId(Character3Index)))
                        {
                            continue;
                        }



                        for (int i3 = 0; i3 < Waypoint1ObjectIndices.Length; i3++)
                        {
                            var Waypoint1Index  = Waypoint1ObjectIndices[i3];
                            var Waypoint1Object = stateData.TraitBasedObjects[Waypoint1Index];



                            if (!(CharacterBuffer[Character1Object.CharacterIndex].Waypoint == stateData.GetTraitBasedObjectId(Waypoint1Index)))
                            {
                                continue;
                            }


                            for (int i4 = 0; i4 < Waypoint2ObjectIndices.Length; i4++)
                            {
                                var Waypoint2Index  = Waypoint2ObjectIndices[i4];
                                var Waypoint2Object = stateData.TraitBasedObjects[Waypoint2Index];



                                if (!(CharacterBuffer[Character2Object.CharacterIndex].Waypoint == stateData.GetTraitBasedObjectId(Waypoint2Index)))
                                {
                                    continue;
                                }

                                for (int i5 = 0; i5 < Waypoint3ObjectIndices.Length; i5++)
                                {
                                    var Waypoint3Index  = Waypoint3ObjectIndices[i5];
                                    var Waypoint3Object = stateData.TraitBasedObjects[Waypoint3Index];



                                    if (!(CharacterBuffer[Character3Object.CharacterIndex].Waypoint == stateData.GetTraitBasedObjectId(Waypoint3Index)))
                                    {
                                        continue;
                                    }
                                    Character1ObjectIndices.Dispose();
                                    Character1Filter.Dispose();
                                    Character2ObjectIndices.Dispose();
                                    Character2Filter.Dispose();
                                    Character3ObjectIndices.Dispose();
                                    Character3Filter.Dispose();
                                    Waypoint1ObjectIndices.Dispose();
                                    Waypoint1Filter.Dispose();
                                    Waypoint2ObjectIndices.Dispose();
                                    Waypoint2Filter.Dispose();
                                    Waypoint3ObjectIndices.Dispose();
                                    Waypoint3Filter.Dispose();
                                    return(true);
                                }
                            }
                        }
                    }
                }
            }
            Character1ObjectIndices.Dispose();
            Character1Filter.Dispose();
            Character2ObjectIndices.Dispose();
            Character2Filter.Dispose();
            Character3ObjectIndices.Dispose();
            Character3Filter.Dispose();
            Waypoint1ObjectIndices.Dispose();
            Waypoint1Filter.Dispose();
            Waypoint2ObjectIndices.Dispose();
            Waypoint2Filter.Dispose();
            Waypoint3ObjectIndices.Dispose();
            Waypoint3Filter.Dispose();

            return(false);
        }