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()
andmatrx.actions.Action.mutate()
should return anmatrx.actions.action.ActionResult
. With the former it represents the expected success or failure of thematrx.actions.action.Action
, with the latter the actual success or failure.The
matrx.actions.action.ActionResult
class contain several reasons why anmatrx.actions.action.Action
may succeed or fail that are being checked by amatrx.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 thatmatrx.actions.action.Action
specific results. This allows anmatrx.agents.agent_brain.AgentBrain
to directly match thematrx.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
Result when the agent is not capable of performing that action.
Result when the action is not expected to succeed.
Result when the action name does not represent an
Action
classResult when the action succeeded or is expected to succeed.
Result string for when the agent was removed before performing its action.
NO_ACTION_GIVEN
Deprecated: Use IDLE_ACTION instead.