in textworld/generator/vtypes.py [0:0]
def __init__(self, vtypes: List[VariableType]):
self.variables_types = {vtype.type: vtype for vtype in vtypes}
# Make some convenient attributes.
self.types = [vt.type for vt in vtypes]
self.names = [vt.name for vt in vtypes]
self.constants = [t for t in self if self.is_constant(t)]
self.variables = [t for t in self if not self.is_constant(t)]
self.constants_mapping = {Placeholder(c): Variable(c) for c in self.constants}
# Adjust variable type's parent and children references.
for vt in vtypes:
if vt.parent is not None:
vt_parent = self[vt.parent]
vt_parent.children.append(vt.type)