matrx.actions.action.ActionResult

class ActionResult(result, succeeded)

Represents the generic (expected) result of an action.

This class functions as a simple wrapper around a boolean representing the success (True) or failure (False) of the (expected) mutation of an matrx.actions.action.Action, as well as the reason for it.

The matrx.actions.action.ActionResult class contains several generic reasons for a succeed or fail as constant class attributes.

Parameters
resultstr

A string representing the reason for the (expected) success or fail of an matrx.actions.action.Action.

succeededbool

A boolean representing the (expected) success or fail of an matrx.actions.action.Action.

See also

Action

The super-class whose children return an ActionResult

Notes

Both the methods matrx.actions.Action.is_possible() and matrx.actions.Action.mutate() should return an matrx.actions.action.ActionResult. With the former it represents the expected success or failure of the matrx.actions.action.Action, with the latter the actual success or failure.

The matrx.actions.action.ActionResult class contain several reasons why an matrx.actions.action.Action may succeed or fail that are being checked by a matrx.grid_world.GridWorld instance. These are:

  • IDLE_ACTION: Always given when an AgentBrain decided upon returning None (the idle action)

  • AGENT_WAS_REMOVED: Always given when an agent does not exist anymore in the GridWorld.

  • AGENT_NOT_CAPABLE: Always given when the Action an AgentBrain decided upon is not an Action that agent should be capable of.

  • UNKNOWN_ACTION: Always given when the Action name an AgentBrain decided upon is not recognized as a class name of an Action or some class inheriting from Action. Could be caused by either that class not existing or because it is never imported anywhere (and hence is not on the path the GridWorld searches in).

When creating a new matrx.actions.action.Action class, you can also extend this class with your own. This allows you to set your own constants representing reasons for that matrx.actions.action.Action specific results. This allows an matrx.agents.agent_brain.AgentBrain to directly match the matrx.actions.ActionResult.result with a constant and potentially adjust its behavior.

__init__(self, result, succeeded)

Initialize self. See help(type(self)) for accurate signature.

Methods

__init__(self, result, succeeded)

Initialize self.

Attributes

ACTION_NOT_POSSIBLE

Result when the agent is not capable of performing that action.

ACTION_SUCCEEDED

Result when the action is not expected to succeed.

AGENT_NOT_CAPABLE

Result when the action name does not represent an Action class

AGENT_WAS_REMOVED

Result when the action succeeded or is expected to succeed.

IDLE_ACTION

Result string for when the agent was removed before performing its action.

NO_ACTION_GIVEN

UNKNOWN_ACTION

Deprecated: Use IDLE_ACTION instead.