new MemorySystem(owner)
Constructs a new memory system.
Parameters:
Name | Type | Default | Description |
---|---|---|---|
owner |
GameEntity | null | The game entity that owns this memory system. |
Members
-
memorySpan :Number
-
Represents the duration of the game entities short term memory in seconds. When a bot requests a list of all recently sensed game entities, this value is used to determine if the bot is able to remember a game entity or not.
- Default Value:
- 1
-
nullable owner :GameEntity
-
The game entity that owns this memory system.
- Default Value:
- null
-
records :Array.<MemoryRecord>
-
Used to simulate memory of sensory events. It contains memory records of all relevant game entities in the environment. The records are usually update by the owner of the memory system.
-
recordsMap :Map.<GameEntity, MemoryRecord>
-
Same as MemorySystem#records but used for fast access via the game entity.
Methods
-
clear() → {MemorySystem}
-
Removes all memory records from the memory system.
-
createRecord(entity) → {MemorySystem}
-
Creates a memory record for the given game entity.
Parameters:
Name Type Description entity
GameEntity The game entity.
-
deleteRecord(entity) → {MemorySystem}
-
Deletes the memory record for the given game entity.
Parameters:
Name Type Description entity
GameEntity The game entity.
-
fromJSON(json) → {MemorySystem}
-
Restores this instance from the given JSON object.
Parameters:
Name Type Description json
Object The JSON object.
-
getRecord(entity) → {MemoryRecord}
-
Returns the memory record of the given game entity.
Parameters:
Name Type Description entity
GameEntity The game entity.
-
getValidMemoryRecords(currentTime, result) → {Array.<MemoryRecord>}
-
Determines all valid memory record and stores the result in the given array.
Parameters:
Name Type Description currentTime
Number The current elapsed time.
result
Array.<MemoryRecord> The result array.
-
hasRecord(entity) → {Boolean}
-
Returns true if there is a memory record for the given game entity.
Parameters:
Name Type Description entity
GameEntity The game entity.
Returns:
Boolean -Whether the game entity has a memory record or not.
-
resolveReferences(entities) → {MemorySystem}
-
Restores UUIDs with references to GameEntity objects.
Parameters:
Name Type Description entities
Map.<String, GameEntity> Maps game entities to UUIDs.
-
toJSON() → {Object}
-
Transforms this instance into a JSON object.
Returns:
Object -The JSON object.