factoriax.engine.actions#
Lookup tables between an item and the action that addresses it.
The name of a PLACE_, CRAFT_, or DEPOSIT_ action contains the name
of the item that the action addresses. An action and an item therefore
determine each other. This module holds both directions as jnp gather
arrays. The item tuples in factoriax.engine.constants supply the
contents.
The two directions answer different questions. *_ACTION_TO_ITEM maps an
action offset to the item that the action addresses. execute_action in
factoriax.engine.step reads this table once it holds an action, and
indexes it with a traced value inside jax.jit. ITEM_TO_*_ACTION maps an
item back to an absolute action. The play UI reads this table to turn a click
on an item into an action, and indexes it on the host with a Python int.
An import of this module runs _validate(). If two tables disagree,
_validate() raises ValueError. The module then fails to import, and
the engine cannot dispatch an action to the wrong item.
Module Attributes
Backward-table entry for an item with no action in that list. |
|
Item placed by each |
|
Item crafted by each |
|
Item deposited by each |
|
|
|
|
|
|
- factoriax.engine.actions.CRAFT_ACTION_TO_ITEM = Array([ 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33], dtype=int32)#
Item crafted by each
CRAFT_action, indexed byaction - CRAFT_BASE.
- factoriax.engine.actions.DEPOSIT_ACTION_TO_ITEM = Array([ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33], dtype=int32)#
Item deposited by each
DEPOSIT_action, indexed byaction - DEPOSIT_BASE.
- factoriax.engine.actions.ITEM_TO_CRAFT_ACTION = Array([-1, -1, -1, -1, -1, -1, -1, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53], dtype=int32)#
CRAFT_action for each item, indexed byItemType.NO_ACTIONfor the raw resources, which are mined rather than crafted, and forEMPTY.
- factoriax.engine.actions.ITEM_TO_DEPOSIT_ACTION = Array([-1, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86], dtype=int32)#
DEPOSIT_action for each item, indexed byItemType.NO_ACTIONatEMPTYand nowhere else: every real item can be deposited.
- factoriax.engine.actions.ITEM_TO_PLACE_ACTION = Array([-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26], dtype=int32)#
PLACE_action for each item, indexed byItemType.NO_ACTIONfor every item that is not a machine,EMPTYincluded.
- factoriax.engine.actions.NO_ACTION: int = -1#
Backward-table entry for an item with no action in that list. The value is negative because
0is itself an action (MoveAction.NOOP). A caller must compare against this value, and must not test truthiness.
- factoriax.engine.actions.PLACE_ACTION_TO_ITEM = Array([24, 25, 26, 27, 28, 29, 30, 31, 32, 33], dtype=int32)#
Item placed by each
PLACE_action, indexed byaction - PLACE_BASE.