MemorySystem(owner)

Class for representing the memory system of a game entity. It is used for managing, filtering, and remembering sensory input.

new MemorySystem(owner)

Constructs a new memory system.

Parameters:
Name Type Default Description
owner GameEntity null

The game entity that owns this memory system.

Author:

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.

Returns:
MemorySystem -

A reference to this memory system.

createRecord(entity) → {MemorySystem}

Creates a memory record for the given game entity.

Parameters:
Name Type Description
entity GameEntity

The game entity.

Returns:
MemorySystem -

A reference to this memory system.

deleteRecord(entity) → {MemorySystem}

Deletes the memory record for the given game entity.

Parameters:
Name Type Description
entity GameEntity

The game entity.

Returns:
MemorySystem -

A reference to this memory system.

fromJSON(json) → {MemorySystem}

Restores this instance from the given JSON object.

Parameters:
Name Type Description
json Object

The JSON object.

Returns:
MemorySystem -

A reference to this memory system.

getRecord(entity) → {MemoryRecord}

Returns the memory record of the given game entity.

Parameters:
Name Type Description
entity GameEntity

The game entity.

Returns:
MemoryRecord -

The memory record for this 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.

Returns:
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.

Returns:
MemorySystem -

A reference to this memory system.

toJSON() → {Object}

Transforms this instance into a JSON object.

Returns:
Object -

The JSON object.