public override void Setup()
 {
     base.Setup();
     m_LargeStateKey = m_StateManager.CopyState(KeyDomainUtility.InitialStateKey);
     m_RoomType      = new NativeArray <ComponentType>(2, Allocator.TempJob)
     {
         [0] = ComponentType.ReadWrite <Lockable>(), [1] = ComponentType.ReadWrite <Colored>()
     };
     Add500Rooms(m_StateManager.GetStateData(m_LargeStateKey, readWrite: true));
 }
Exemplo n.º 2
0
        public static void Initialize(World world)
        {
            RoomArchetype = new ComponentType[] { ComponentType.ReadWrite <Lockable>(), ComponentType.ReadWrite <Colored>(), ComponentType.ReadWrite <TraitBasedObjectId>() };

            StateManager = world.GetOrCreateSystem <StateManager>();
            var stateData = StateManager.CreateStateData();

            (BlackKey, BlackKeyId)   = CreateKey(stateData, ColorValue.Black);
            (WhiteKey, WhiteKeyId)   = CreateKey(stateData, ColorValue.White);
            (StartRoom, StartRoomId) = CreateRoom(stateData, ColorValue.Black, false);
            (FirstRoom, FirstRoomId) = CreateRoom(stateData, ColorValue.White);
            (Agent, AgentId)         = CreateAgent(stateData, BlackKeyId, StartRoomId);

            InitialStateKey = StateManager.GetStateDataKey(stateData);
        }
Exemplo n.º 3
0
        NativeArray <StateTransitionInfoPair <StateEntityKey, ActionKey, StateTransitionInfo> > ApplyEffects(ActionKey action, StateEntityKey originalStateEntityKey)
        {
            var results = new NativeArray <StateTransitionInfoPair <StateEntityKey, ActionKey, StateTransitionInfo> >(3, Allocator.Temp);

            results[0] = CreateResultingState(originalStateEntityKey, action, ColorValue.Black, 0.4f, 1f, false);
            results[1] = CreateResultingState(originalStateEntityKey, action, ColorValue.White, 0.4f, 1f, false);
            results[2] = CreateResultingState(originalStateEntityKey, action, ColorValue.Black, 0.2f, 10f, true);

            return(results);
        }
Exemplo n.º 4
0
        StateTransitionInfoPair <StateEntityKey, ActionKey, StateTransitionInfo> ApplyEffects(ActionKey action, StateEntityKey originalStateEntityKey)
        {
            var originalState             = m_StateDataContext.GetStateData(originalStateEntityKey);
            var originalStateObjectBuffer = originalState.TraitBasedObjects;
            var originalGameObject        = originalStateObjectBuffer[action[k_GameIndex]];

            var newState      = m_StateDataContext.CopyStateData(originalState);
            var newGameBuffer = newState.GameBuffer;
            {
                var @Game = newGameBuffer[originalGameObject.GameIndex];
                @Game.@MoveCount += 1;
                newGameBuffer[originalGameObject.GameIndex] = @Game;
            }
            {
                new CustomSwapEffect().ApplyCustomActionEffectsToState(originalState, action, newState);
            }



            var reward = Reward(originalState, action, newState);
            var StateTransitionInfo = new StateTransitionInfo {
                Probability = 1f, TransitionUtilityValue = reward
            };
            var resultingStateKey = m_StateDataContext.GetStateDataKey(newState);

            return(new StateTransitionInfoPair <StateEntityKey, ActionKey, StateTransitionInfo>(originalStateEntityKey, action, resultingStateKey, StateTransitionInfo));
        }
        StateTransitionInfoPair <StateEntityKey, ActionKey, StateTransitionInfo> ApplyEffects(ActionKey action, StateEntityKey originalStateEntityKey)
        {
            var originalState             = m_StateDataContext.GetStateData(originalStateEntityKey);
            var originalStateObjectBuffer = originalState.TraitBasedObjects;
            var originalNPCObject         = originalStateObjectBuffer[action[k_NPCIndex]];
            var originalWayPointObject    = originalStateObjectBuffer[action[k_WayPointIndex]];

            var newState          = m_StateDataContext.CopyStateData(originalState);
            var newLocationBuffer = newState.LocationBuffer;
            {
                var @Location = newLocationBuffer[originalNPCObject.LocationIndex];
                @Location.Position = newLocationBuffer[originalWayPointObject.LocationIndex].Position;
                newLocationBuffer[originalNPCObject.LocationIndex] = @Location;
            }



            var reward = Reward(originalState, action, newState);
            var StateTransitionInfo = new StateTransitionInfo {
                Probability = 1f, TransitionUtilityValue = reward
            };
            var resultingStateKey = m_StateDataContext.GetStateDataKey(newState);

            return(new StateTransitionInfoPair <StateEntityKey, ActionKey, StateTransitionInfo>(originalStateEntityKey, action, resultingStateKey, StateTransitionInfo));
        }
Exemplo n.º 6
0
        StateTransitionInfoPair <StateEntityKey, ActionKey, StateTransitionInfo> ApplyEffects(ActionKey action, StateEntityKey originalStateEntityKey)
        {
            var originalState             = m_StateDataContext.GetStateData(originalStateEntityKey);
            var originalStateObjectBuffer = originalState.TraitBasedObjects;
            var originalRobotObject       = originalStateObjectBuffer[action[k_RobotIndex]];

            var newState       = m_StateDataContext.CopyStateData(originalState);
            var newRobotBuffer = newState.RobotBuffer;
            {
                var @Robot = newRobotBuffer[originalRobotObject.RobotIndex];
                @Robot.@Battery += 10;
                newRobotBuffer[originalRobotObject.RobotIndex] = @Robot;
            }



            var reward = Reward(originalState, action, newState);
            var StateTransitionInfo = new StateTransitionInfo {
                Probability = 1f, TransitionUtilityValue = reward
            };
            var resultingStateKey = m_StateDataContext.GetStateDataKey(newState);

            return(new StateTransitionInfoPair <StateEntityKey, ActionKey, StateTransitionInfo>(originalStateEntityKey, action, resultingStateKey, StateTransitionInfo));
        }
Exemplo n.º 7
0
        StateTransitionInfoPair <StateEntityKey, ActionKey, StateTransitionInfo> ApplyEffects(ActionKey action, StateEntityKey originalStateEntityKey)
        {
            var originalState             = m_StateDataContext.GetStateData(originalStateEntityKey);
            var originalStateObjectBuffer = originalState.TraitBasedObjects;
            var originalItemObject        = originalStateObjectBuffer[action[k_ItemIndex]];
            var originalCharacterObject   = originalStateObjectBuffer[action[k_CharacterIndex]];

            var newState           = m_StateDataContext.CopyStateData(originalState);
            var newCarriableBuffer = newState.CarriableBuffer;
            var newCarrierBuffer   = newState.CarrierBuffer;
            {
                var @Carriable = newCarriableBuffer[originalItemObject.CarriableIndex];
                @Carriable.@CarriedBy = originalState.GetTraitBasedObjectId(originalCharacterObject);
                newCarriableBuffer[originalItemObject.CarriableIndex] = @Carriable;
            }
            {
                var @Carrier = newCarrierBuffer[originalCharacterObject.CarrierIndex];
                @Carrier.@Carried = originalState.GetTraitBasedObjectId(originalItemObject);
                newCarrierBuffer[originalCharacterObject.CarrierIndex] = @Carrier;
            }



            var reward = Reward(originalState, action, newState);
            var StateTransitionInfo = new StateTransitionInfo {
                Probability = 1f, TransitionUtilityValue = reward
            };
            var resultingStateKey = m_StateDataContext.GetStateDataKey(newState);

            return(new StateTransitionInfoPair <StateEntityKey, ActionKey, StateTransitionInfo>(originalStateEntityKey, action, resultingStateKey, StateTransitionInfo));
        }
        StateTransitionInfoPair <StateEntityKey, ActionKey, StateTransitionInfo> ApplyEffects(ActionKey action, StateEntityKey originalStateEntityKey)
        {
            var originalState             = m_StateDataContext.GetStateData(originalStateEntityKey);
            var originalStateObjectBuffer = originalState.TraitBasedObjects;
            var newState = m_StateDataContext.CopyStateData(originalState);

            var originalObjectIds = originalState.TraitBasedObjectIds;

            // Action effects
            var oldKeyIndex = action[k_KeyIndex];

            var newCarriableBuffer = newState.CarriableBuffer;
            var newCarrierBuffer   = newState.CarrierBuffer;

            {
                if (oldKeyIndex >= 0)
                {
                    newCarriableBuffer[oldKeyIndex] = new Carriable()
                    {
                        Carrier = ObjectId.None
                    }
                }
                ;
            }

            {
                newCarriableBuffer[originalStateObjectBuffer[action[k_KeyIndex]].CarriableIndex] =
                    new Carriable()
                {
                    Carrier = originalObjectIds[action[k_AgentIndex]].Id
                };
            }

            {
                newCarrierBuffer[originalStateObjectBuffer[action[k_AgentIndex]].CarrierIndex] =
                    new Carrier()
                {
                    CarriedObject = originalObjectIds[action[k_KeyIndex]].Id
                };
            }

            var reward = Reward(originalState, action, newState);
            var StateTransitionInfo = new StateTransitionInfo {
                Probability = 1f, TransitionUtilityValue = reward
            };
            var resultingStateKey = m_StateDataContext.GetStateDataKey(newState);

            return(new StateTransitionInfoPair <StateEntityKey, ActionKey, StateTransitionInfo>(originalStateEntityKey, action, resultingStateKey, StateTransitionInfo));
        }

        float Reward(StateData originalState, ActionKey action, StateData newState)
        {
            return(-1f);
        }
Exemplo n.º 9
0
        StateTransitionInfoPair <StateEntityKey, ActionKey, StateTransitionInfo> ApplyEffects(ActionKey action, StateEntityKey originalStateEntityKey)
        {
            var originalState             = m_StateDataContext.GetStateData(originalStateEntityKey);
            var originalStateObjectBuffer = originalState.TraitBasedObjects;
            var originalCoverObject       = originalStateObjectBuffer[action[k_CoverIndex]];
            var originalAgentObject       = originalStateObjectBuffer[action[k_AgentIndex]];

            var newState          = m_StateDataContext.CopyStateData(originalState);
            var newCoverBuffer    = newState.CoverBuffer;
            var newLocationBuffer = newState.LocationBuffer;
            var newAgentBuffer    = newState.AgentBuffer;
            {
                var @Cover = newCoverBuffer[originalCoverObject.CoverIndex];
                @Cover.@SpotTaken = true;
                newCoverBuffer[originalCoverObject.CoverIndex] = @Cover;
            }
            {
                var @Location = newLocationBuffer[originalAgentObject.LocationIndex];
                @Location.Position = newLocationBuffer[originalCoverObject.LocationIndex].Position;
                newLocationBuffer[originalAgentObject.LocationIndex] = @Location;
            }
            {
                var @Agent = newAgentBuffer[originalAgentObject.AgentIndex];
                @Agent.@Safe = true;
                newAgentBuffer[originalAgentObject.AgentIndex] = @Agent;
            }
            {
                var @Agent = newAgentBuffer[originalAgentObject.AgentIndex];
                @Agent.@Timeline += 1;
                newAgentBuffer[originalAgentObject.AgentIndex] = @Agent;
            }



            var reward = Reward(originalState, action, newState);
            var StateTransitionInfo = new StateTransitionInfo {
                Probability = 1f, TransitionUtilityValue = reward
            };
            var resultingStateKey = m_StateDataContext.GetStateDataKey(newState);

            return(new StateTransitionInfoPair <StateEntityKey, ActionKey, StateTransitionInfo>(originalStateEntityKey, action, resultingStateKey, StateTransitionInfo));
        }
Exemplo n.º 10
0
        StateTransitionInfoPair <StateEntityKey, ActionKey, StateTransitionInfo> ApplyEffects(ActionKey action, StateEntityKey originalStateEntityKey)
        {
            var originalState             = m_StateDataContext.GetStateData(originalStateEntityKey);
            var originalStateObjectBuffer = originalState.TraitBasedObjects;
            var originalAgentObject       = originalStateObjectBuffer[action[k_AgentIndex]];
            var originalItemObject        = originalStateObjectBuffer[action[k_ItemIndex]];

            var newState          = m_StateDataContext.CopyStateData(originalState);
            var newAgentBuffer    = newState.AgentBuffer;
            var newLocationBuffer = newState.LocationBuffer;
            var newItemBuffer     = newState.ItemBuffer;
            {
                var @Agent = newAgentBuffer[originalAgentObject.AgentIndex];
                @Agent.@HasWeapon = true;
                newAgentBuffer[originalAgentObject.AgentIndex] = @Agent;
            }
            {
                var @Location = newLocationBuffer[originalAgentObject.LocationIndex];
                @Location.Position = newLocationBuffer[originalItemObject.LocationIndex].Position;
                newLocationBuffer[originalAgentObject.LocationIndex] = @Location;
            }
            {
                var @Item = newItemBuffer[originalItemObject.ItemIndex];
                @Item.@CarriedBy = originalState.GetTraitBasedObjectId(originalAgentObject);
                newItemBuffer[originalItemObject.ItemIndex] = @Item;
            }
            {
                var @Agent = newAgentBuffer[originalAgentObject.AgentIndex];
                @Agent.@Timeline += 1;
                newAgentBuffer[originalAgentObject.AgentIndex] = @Agent;
            }



            var reward = Reward(originalState, action, newState);
            var StateTransitionInfo = new StateTransitionInfo {
                Probability = 1f, TransitionUtilityValue = reward
            };
            var resultingStateKey = m_StateDataContext.GetStateDataKey(newState);

            return(new StateTransitionInfoPair <StateEntityKey, ActionKey, StateTransitionInfo>(originalStateEntityKey, action, resultingStateKey, StateTransitionInfo));
        }
Exemplo n.º 11
0
        StateTransitionInfoPair <StateEntityKey, ActionKey, StateTransitionInfo> ApplyEffects(ActionKey action, StateEntityKey originalStateEntityKey)
        {
            var originalState             = m_StateDataContext.GetStateData(originalStateEntityKey);
            var originalStateObjectBuffer = originalState.TraitBasedObjects;
            var originalAgentObject       = originalStateObjectBuffer[action[k_AgentIndex]];

            var newState       = m_StateDataContext.CopyStateData(originalState);
            var newAgentBuffer = newState.AgentBuffer;
            {
                var @Agent = newAgentBuffer[originalAgentObject.AgentIndex];
                @Agent.@Navigating = true;
                newAgentBuffer[originalAgentObject.AgentIndex] = @Agent;
            }



            var reward = Reward(originalState, action, newState);
            var StateTransitionInfo = new StateTransitionInfo {
                Probability = 1f, TransitionUtilityValue = reward
            };
            var resultingStateKey = m_StateDataContext.GetStateDataKey(newState);

            return(new StateTransitionInfoPair <StateEntityKey, ActionKey, StateTransitionInfo>(originalStateEntityKey, action, resultingStateKey, StateTransitionInfo));
        }
Exemplo n.º 12
0
        StateTransitionInfoPair <StateEntityKey, ActionKey, StateTransitionInfo> ApplyEffects(ActionKey action, StateEntityKey originalStateEntityKey)
        {
            var originalState             = m_StateDataContext.GetStateData(originalStateEntityKey);
            var originalStateObjectBuffer = originalState.TraitBasedObjects;

            // effect params
            var originalAgentObject = originalStateObjectBuffer[action[k_AgentIndex]];
            var originalRoomObject  = originalStateObjectBuffer[action[k_RoomIndex]];

            var newState = m_StateDataContext.CopyStateData(originalState);

            var newLocalizedBuffer           = newState.LocalizedBuffer;
            var newTraitBasedObjectIdsBuffer = newState.TraitBasedObjectIds;

            // Action effects
            {
                var @Localized          = newLocalizedBuffer[originalAgentObject.LocalizedIndex];
                var @TraitBasedObjectId = newTraitBasedObjectIdsBuffer[action[k_RoomIndex]];
                @Localized.Location = @TraitBasedObjectId.Id;
                newLocalizedBuffer[originalAgentObject.LocalizedIndex] = @Localized;
            }

            var reward = Reward(originalState, action, newState);
            var StateTransitionInfo = new StateTransitionInfo {
                Probability = 1f, TransitionUtilityValue = reward
            };
            var resultingStateKey = m_StateDataContext.GetStateDataKey(newState);

            return(new StateTransitionInfoPair <StateEntityKey, ActionKey, StateTransitionInfo>(originalStateEntityKey, action, resultingStateKey, StateTransitionInfo));
        }
        StateTransitionInfoPair <StateEntityKey, ActionKey, StateTransitionInfo> ApplyEffects(ActionKey action, StateEntityKey originalStateEntityKey)
        {
            var originalState             = m_StateDataContext.GetStateData(originalStateEntityKey);
            var originalStateObjectBuffer = originalState.TraitBasedObjects;
            var originalGameStateObject   = originalStateObjectBuffer[action[k_GameStateIndex]];
            var originalNPCObject         = originalStateObjectBuffer[action[k_NPCIndex]];
            var originalGateObject        = originalStateObjectBuffer[action[k_GateIndex]];

            var newState            = m_StateDataContext.CopyStateData(originalState);
            var newGateSwitchBuffer = newState.GateSwitchBuffer;
            var newBaggageBuffer    = newState.BaggageBuffer;
            {
                var @GateSwitch = newGateSwitchBuffer[originalGameStateObject.GateSwitchIndex];
                @GateSwitch.@OpenCount += 1;
                newGateSwitchBuffer[originalGameStateObject.GateSwitchIndex] = @GateSwitch;
            }
            {
                var @Baggage = newBaggageBuffer[originalNPCObject.BaggageIndex];
                @Baggage.@HasItem = false;
                newBaggageBuffer[originalNPCObject.BaggageIndex] = @Baggage;
            }
            {
                var @Baggage = newBaggageBuffer[originalGateObject.BaggageIndex];
                @Baggage.@HasItem = true;
                newBaggageBuffer[originalGateObject.BaggageIndex] = @Baggage;
            }



            var reward = Reward(originalState, action, newState);
            var StateTransitionInfo = new StateTransitionInfo {
                Probability = 1f, TransitionUtilityValue = reward
            };
            var resultingStateKey = m_StateDataContext.GetStateDataKey(newState);

            return(new StateTransitionInfoPair <StateEntityKey, ActionKey, StateTransitionInfo>(originalStateEntityKey, action, resultingStateKey, StateTransitionInfo));
        }
Exemplo n.º 14
0
        StateTransitionInfoPair <StateEntityKey, ActionKey, StateTransitionInfo> ApplyEffects(ActionKey action, StateEntityKey originalStateEntityKey)
        {
            var originalState             = m_StateDataContext.GetStateData(originalStateEntityKey);
            var originalStateObjectBuffer = originalState.TraitBasedObjects;
            var originalNPCObject         = originalStateObjectBuffer[action[k_NPCIndex]];

            var newState         = m_StateDataContext.CopyStateData(originalState);
            var newBaggageBuffer = newState.BaggageBuffer;

            {
                var @Baggage = newBaggageBuffer[originalNPCObject.BaggageIndex];
                @Baggage.@HasItem = true;
                newBaggageBuffer[originalNPCObject.BaggageIndex] = @Baggage;
            }


            newState.RemoveTraitBasedObjectAtIndex(action[k_ItemIndex]);

            var reward = Reward(originalState, action, newState);
            var StateTransitionInfo = new StateTransitionInfo {
                Probability = 1f, TransitionUtilityValue = reward
            };
            var resultingStateKey = m_StateDataContext.GetStateDataKey(newState);

            return(new StateTransitionInfoPair <StateEntityKey, ActionKey, StateTransitionInfo>(originalStateEntityKey, action, resultingStateKey, StateTransitionInfo));
        }
Exemplo n.º 15
0
        StateTransitionInfoPair <StateEntityKey, ActionKey, StateTransitionInfo> CreateResultingState(StateEntityKey originalStateEntityKey, ActionKey action,
                                                                                                      ColorValue roomColor, float probability, float reward, bool endRoom)
        {
            var originalState             = m_StateDataContext.GetStateData(originalStateEntityKey);
            var originalStateObjectBuffer = originalState.TraitBasedObjects;

            var newState = m_StateDataContext.CopyStateData(originalState);

            var newObjectBuffer    = newState.TraitBasedObjects;
            var newDomainIdBuffer  = newState.TraitBasedObjectIds;
            var newLockableBuffer  = newState.LockableBuffer;
            var newColoredBuffer   = newState.ColoredBuffer;
            var newLocalizedBuffer = newState.LocalizedBuffer;
            var newEndBuffer       = newState.EndBuffer;

            // Action effects
            newState.AddTraitBasedObject(s_RoomTypes, out var newRoom, out _);
            var newRoomIndex = newState.GetTraitBasedObjectIndex(newRoom);

            var newRoomLockable = newState.GetTraitOnObject <Lockable>(newRoom);

            newRoomLockable.Locked = true;
            newState.SetTraitOnObjectAtIndex(newRoomLockable, newRoomIndex);

            var newRoomColor = newState.GetTraitOnObject <Colored>(newRoom);

            newRoomColor.Color = roomColor;
            newState.SetTraitOnObjectAtIndex(newRoomColor, newRoomIndex);

            {
                newLockableBuffer[newObjectBuffer[action[k_RoomIndex]].LockableIndex] = new Lockable {
                    Locked = false
                };
                newLocalizedBuffer[newObjectBuffer[action[k_AgentIndex]].LocalizedIndex] = new Localized {
                    Location = newDomainIdBuffer[newRoomIndex].Id
                };
            }

            if (endRoom)
            {
                newEndBuffer.Add(new End());
                newRoom.EndIndex = (byte)(newEndBuffer.Length - 1);
                newObjectBuffer[newObjectBuffer.Length - 1] = newRoom;
            }

            var StateTransitionInfo = new StateTransitionInfo {
                Probability = probability, TransitionUtilityValue = reward
            };
            var resultingStateKey = m_StateDataContext.GetStateDataKey(newState);

            return(new StateTransitionInfoPair <StateEntityKey, ActionKey, StateTransitionInfo>(originalStateEntityKey, action, resultingStateKey, StateTransitionInfo));
        }
Exemplo n.º 16
0
        StateTransitionInfoPair <StateEntityKey, ActionKey, StateTransitionInfo> ApplyEffects(ActionKey action, StateEntityKey originalStateEntityKey)
        {
            var originalState             = m_StateDataContext.GetStateData(originalStateEntityKey);
            var originalStateObjectBuffer = originalState.TraitBasedObjects;

            var newState = m_StateDataContext.CopyStateData(originalState);


            newState.RemoveTraitBasedObjectAtIndex(action[k_DirtIndex]);

            var reward = Reward(originalState, action, newState);
            var StateTransitionInfo = new StateTransitionInfo {
                Probability = 1f, TransitionUtilityValue = reward
            };
            var resultingStateKey = m_StateDataContext.GetStateDataKey(newState);

            return(new StateTransitionInfoPair <StateEntityKey, ActionKey, StateTransitionInfo>(originalStateEntityKey, action, resultingStateKey, StateTransitionInfo));
        }
Exemplo n.º 17
0
        StateTransitionInfoPair <StateEntityKey, ActionKey, StateTransitionInfo> ApplyEffects(ActionKey action, StateEntityKey originalStateEntityKey)
        {
            var originalState             = m_StateDataContext.GetStateData(originalStateEntityKey);
            var originalStateObjectBuffer = originalState.TraitBasedObjects;
            var originalCharacterObject   = originalStateObjectBuffer[action[k_CharacterIndex]];
            var originalToObject          = originalStateObjectBuffer[action[k_ToIndex]];
            var originalFromObject        = originalStateObjectBuffer[action[k_FromIndex]];

            var newState           = m_StateDataContext.CopyStateData(originalState);
            var newCharacterBuffer = newState.CharacterBuffer;
            var newWaypointBuffer  = newState.WaypointBuffer;
            {
                var @Character = newCharacterBuffer[originalCharacterObject.CharacterIndex];
                @Character.@Waypoint = originalState.GetTraitBasedObjectId(originalToObject);
                newCharacterBuffer[originalCharacterObject.CharacterIndex] = @Character;
            }
            {
                var @Waypoint = newWaypointBuffer[originalToObject.WaypointIndex];
                @Waypoint.@Occupied = true;
                newWaypointBuffer[originalToObject.WaypointIndex] = @Waypoint;
            }
            {
                var @Waypoint = newWaypointBuffer[originalFromObject.WaypointIndex];
                @Waypoint.@Occupied = false;
                newWaypointBuffer[originalFromObject.WaypointIndex] = @Waypoint;
            }
            {
                var @Waypoint = newWaypointBuffer[originalToObject.WaypointIndex];
                @Waypoint.@Visited += 1;
                newWaypointBuffer[originalToObject.WaypointIndex] = @Waypoint;
            }



            var reward = Reward(originalState, action, newState);
            var StateTransitionInfo = new StateTransitionInfo {
                Probability = 1f, TransitionUtilityValue = reward
            };
            var resultingStateKey = m_StateDataContext.GetStateDataKey(newState);

            return(new StateTransitionInfoPair <StateEntityKey, ActionKey, StateTransitionInfo>(originalStateEntityKey, action, resultingStateKey, StateTransitionInfo));
        }
Exemplo n.º 18
0
        StateTransitionInfoPair <StateEntityKey, ActionKey, StateTransitionInfo> ApplyEffects(ActionKey action, StateEntityKey originalStateEntityKey)
        {
            var originalState             = m_StateDataContext.GetStateData(originalStateEntityKey);
            var originalStateObjectBuffer = originalState.TraitBasedObjects;
            var originalRobotObject       = originalStateObjectBuffer[action[k_RobotIndex]];

            var newState             = m_StateDataContext.CopyStateData(originalState);
            var newCleanlinessBuffer = newState.CleanlinessBuffer;

            {
                var @Cleanliness = newCleanlinessBuffer[originalRobotObject.CleanlinessIndex];
                @Cleanliness.@DirtCount -= 1;
                newCleanlinessBuffer[originalRobotObject.CleanlinessIndex] = @Cleanliness;
            }


            newState.RemoveTraitBasedObjectAtIndex(action[k_DirtIndex]);

            var reward = Reward(originalState, action, newState);
            var StateTransitionInfo = new StateTransitionInfo {
                Probability = 1f, TransitionUtilityValue = reward
            };
            var resultingStateKey = m_StateDataContext.GetStateDataKey(newState);

            return(new StateTransitionInfoPair <StateEntityKey, ActionKey, StateTransitionInfo>(originalStateEntityKey, action, resultingStateKey, StateTransitionInfo));
        }