Decoders
Decoders are used to translate actions received from the agent’s policy into messages that are sent in the network to other actors and mutators that can update the agent’s own state:
Decoders are a fully optional feature of Phantom. There is no functional difference
between defining an decode_action()
method on an Agent and defining an
Decoder
(whose decode()
method performs the same actions) and attaching
it to the Agent.
Decoders are useful when many different Agents want to decode the same properties and
code re-use is desirable. It is also possible to compose multiple decoders (see
ChainedDecoder
), allowing the construction of complex decoders from many
smaller parts.
Base Decoder
- class phantom.decoders.Decoder(*args, **kwds)[source]
A trait for types that decode raw actions into packets.
- abstract property action_space: Space
The action/input space of the decoder type.
- chain(others)[source]
Chains this decoder together with adjoint set of decoders.
This method returns a
ChainedDecoder
instance where the action space reduces to a tuple with each element given by the action space specified in each of the decoders provided.- Return type:
Provided Implementations
- class phantom.decoders.EmptyDecoder(*args, **kwds)[source]
Converts any actions into empty packets.
- property action_space: Space
The action/input space of the decoder type.
- chain(others)
Chains this decoder together with adjoint set of decoders.
This method returns a
ChainedDecoder
instance where the action space reduces to a tuple with each element given by the action space specified in each of the decoders provided.- Return type:
- reset()
Resets the decoder.
- class phantom.decoders.ChainedDecoder(decoders)[source]
Combines n decoders into a single decoder with a tuple action space.
- decoders
An iterable collection of decoders which is flattened into a list.
- property action_space: Space
The action/input space of the decoder type.
- chain(others)[source]
Chains this decoder together with adjoint set of decoders.
This method returns a
ChainedDecoder
instance where the action space reduces to a tuple with each element given by the action space specified in each of the decoders provided.- Return type: