Goal(owner)

Base class for representing a goal in context of Goal-driven agent design.

new Goal(owner)

Constructs a new goal.

Parameters:
Name Type Default Description
owner GameEntity null

The owner of this goal.

Author:

Members

nullable owner :GameEntity

The owner of this goal.

Default Value:
  • null

status :Status

The status of this goal.

Default Value:
  • INACTIVE

Methods

activate()

Executed when this goal is activated.

activateIfInactive() → {Goal}

Ensures the goal is activated if it is inactive.

Returns:
Goal -

A reference to this goal.

active() → {Boolean}

Returns true if the status of this goal is ACTIVE.

Returns:
Boolean -

Whether the goal is active or not.

completed() → {Boolean}

Returns true if the status of this goal is COMPLETED.

Returns:
Boolean -

Whether the goal is completed or not.

execute()

Executed in each simulation step.

failed() → {Boolean}

Returns true if the status of this goal is FAILED.

Returns:
Boolean -

Whether the goal is failed or not.

fromJSON(json) → {Goal}

Restores this instance from the given JSON object.

Parameters:
Name Type Description
json Object

The JSON object.

Returns:
Goal -

A reference to this goal.

handleMessage(telegram) → {Boolean}

Goals can handle messages. Many don't though, so this defines a default behavior

Parameters:
Name Type Description
telegram Telegram

The telegram with the message data.

Returns:
Boolean -

Whether the message was processed or not.

inactive() → {Boolean}

Returns true if the status of this goal is INACTIVE.

Returns:
Boolean -

Whether the goal is inactive or not.

replanIfFailed() → {Goal}

Ensures the goal is replanned if it has failed.

Returns:
Goal -

A reference to this goal.

resolveReferences(entities) → {Goal}

Restores UUIDs with references to GameEntity objects.

Parameters:
Name Type Description
entities Map.<String, GameEntity>

Maps game entities to UUIDs.

Returns:
Goal -

A reference to this goal.

terminate()

Executed when this goal is satisfied.

toJSON() → {Object}

Transforms this instance into a JSON object.

Returns:
Object -

The JSON object.