yawning_titan.game_modes.game_mode.GameMode#
- class yawning_titan.game_modes.game_mode.GameMode(doc=None, red=None, blue=None, game_rules=None, observation_space=None, on_reset=None, rewards=None, miscellaneous=None, _doc_metadata=None)[source]#
Bases:
ConfigGroup
,DocMetaDataObject
All options to configure and represent a complete game mode.
The ConfigGroup constructor.
- Parameters:
doc – The groups doc.
Methods
Generate a formatted instance of :class: GameMode from stored data.
Generate a formatted instance of :class: GameMode from stored data.
Get the attributes of the class that are either :class: ConfigGroup or
ConfigItem
.Get all attributes of the class that are not :class: ConfigGroup or :class: ConfigItem.
Set the values of all :class: ConfigGroup or
ConfigItem
elements.Set the elements of the group from a .yaml file.
Represent the class as a string.
Convert the group into a unitary depth dictionary of legacy config value (aliases) to :class: ConfigItem's.
Save the values of the elements of the group to a .yaml file.
Validate the grouped items against their properties.
Call the .validate() method on each of the elements in the group.
Attributes
~yawning_titan.config.core.ConfigGroup children of the group.
~yawning_titan.config.core.ConfigItem children of the group.
The configs document metadata.
- classmethod create_from_yaml(yaml=None, legacy=False, infer_legacy=True)[source]#
Generate a formatted instance of :class: GameMode from stored data.
- Parameters:
yaml – A yaml dictionary in the format generated by the to_yaml method.
legacy – Whether the dictionary will be in legacy format.
infer_legacy – Whether to try to set the legacy parameter based upon the keys in the dictionary.
- Returns:
An instance of :class: GameMode.
- classmethod create(dict=None, legacy=False, infer_legacy=True, raise_errors=False)[source]#
Generate a formatted instance of :class: GameMode from stored data.
- Parameters:
dict – A nested dictionary in the format generated by the to_dict method.
legacy – Whether the dictionary will be in legacy format.
infer_legacy – Whether to try to set the legacy parameter based upon the keys in the dictionary.
- Returns:
An instance of :class: GameMode.
- property config_groups#
~yawning_titan.config.core.ConfigGroup children of the group.
- Type:
Property to represent the
- Type:
class
- property config_items#
~yawning_titan.config.core.ConfigItem children of the group.
- Type:
Property to represent the
- Type:
class
- property doc_metadata#
The configs document metadata.
- get_config_elements(types=None)#
Get the attributes of the class that are either :class: ConfigGroup or
ConfigItem
.- Parameters:
_type – An optional type for a specific type of config element.
- Returns:
A dictionary of names to config elements.
- get_non_config_elements()#
Get all attributes of the class that are not :class: ConfigGroup or :class: ConfigItem.
- Returns:
A dictionary of names to attributes.
- set_from_dict(config_dict, legacy=False, infer_legacy=False, **kwargs)#
Set the values of all :class: ConfigGroup or
ConfigItem
elements.- Parameters:
config_dict – A dictionary representing values of all config elements.
legacy – Whether to use the alias names for config elements to construct the config from a legacy dictionary.
infer_legacy – Attempt to recognise if a config is of a legacy type.
- kwargs can contain 2 parameters:
- root: Whether the element is a base level element or not.
if the element is a root then it should validate all of its descendants.
legacy_lookup: The current flattened dictionary representation of the class by its legacy keys.
- set_from_yaml(file_path, legacy=False, infer_legacy=False)#
Set the elements of the group from a .yaml file.
- Parameters:
file_path – The path to the .yaml file.
legacy – Whether to use the alias names for config elements to construct the config from a legacy dictionary.
infer_legacy – Attempt to recognise if a config is of a legacy type.
- stringify()#
Represent the class as a string.
- Returns:
A string.
- to_legacy_dict(flattened_dict=None)#
Convert the group into a unitary depth dictionary of legacy config value (aliases) to :class: ConfigItem’s.
- Returns:
a dictionary
- to_yaml(file_path)#
Save the values of the elements of the group to a .yaml file.
- Parameters:
file_path – The path to the .yaml file
- validate(raise_overall_exception=False)#
Validate the grouped items against their properties.
- Returns:
An instance of
ConfigGroupValidation
.
- validate_elements()#
Call the .validate() method on each of the elements in the group.