World¶
-
class
textworld.generator.world.World(kb=None)[source]¶ Bases:
object-
find_object_by_id(id)[source]¶ - Return type
Optional[WorldObject]
-
classmethod
from_map(map, kb=None)[source]¶ - Parameters
map (
Graph) – Graph defining the structure of the world.- Return type
-
get_all_objects_in(obj)[source]¶ - Return type
List[WorldObject]
-
get_entities_per_type(type)[source]¶ Get all entities of a certain type.
- Return type
List[WorldEntity]
-
get_facts_in_scope()[source]¶ - Return type
List[Proposition]
-
get_objects_in_inventory()[source]¶ - Return type
List[WorldObject]
-
get_visible_objects_in(obj)[source]¶ - Return type
List[WorldObject]
-
populate(nb_objects, rng=None, object_types_probs=None)[source]¶ - Return type
List[Proposition]
-
populate_room(nb_objects, room, rng=None, object_types_probs=None)[source]¶ - Return type
List[Proposition]
-
populate_room_with(objects, room, rng=None)[source]¶ - Return type
List[Proposition]
-
populate_with(objects, rng=None)[source]¶ - Return type
List[Proposition]
-
property
entities¶ - Return type
ValuesView[WorldEntity]
-
property
facts¶ - Return type
List[Proposition]
-
property
objects¶ - Return type
List[WorldObject]
-
-
class
textworld.generator.world.WorldEntity(*args, **kwargs)[source]¶ Bases:
textworld.logic.VariableA WorldEntity is an abstract concept representing anything with a name and a type.
Create a Variable.
- Parameters
name – The (unique) name of the variable.
type (optional) – The type of the variable. Defaults to the same as the name.
- Return type
None
-
classmethod
create(var)[source]¶ - Return type
Union[WorldRoom,WorldObject]
-
get_attributes()[source]¶ - Return type
List[Proposition]
-
property
id¶ - Return type
str
-
name¶
-
type¶
-
class
textworld.generator.world.WorldObject(*args, **kwargs)[source]¶ Bases:
textworld.generator.world.WorldEntityA WorldObject is anything we can directly interact with.
Create a Variable.
- Parameters
name – The (unique) name of the variable.
type (optional) – The type of the variable. Defaults to the same as the name.
-
name¶
-
type¶
-
class
textworld.generator.world.WorldRoom(*args, **kwargs)[source]¶ Bases:
textworld.generator.world.WorldEntityWorldRooms can be linked with each other through exits.
Create a Variable.
- Parameters
name – The (unique) name of the variable.
type (optional) – The type of the variable. Defaults to the same as the name.
-
name¶
-
type¶
-
textworld.generator.world.connect(room1, direction, room2, door=None)[source]¶ Generate predicates that connect two rooms.
- Parameters
- Return type
List[Proposition]
-
textworld.generator.world.graph2state(G, rooms)[source]¶ Convert Graph object to a list of
Proposition.- Parameters
G (
Graph) – Graph defining the structure of the world.rooms (
Dict[str,Variable]) – information about the rooms in the world.
- Return type
List[Proposition]
-
textworld.generator.graph_networks.create_map(rng, n_nodes, h, w, possible_door_states=['open', 'closed', 'locked'])[source]¶
-
textworld.generator.graph_networks.create_small_map(rng, n_rooms, possible_door_states=['open', 'closed', 'locked'])[source]¶
-
textworld.generator.graph_networks.extremes(G)[source]¶ Find left most and bottom nodes in the cartesian sense.
-
textworld.generator.graph_networks.gen_layout(rng, n_nodes=5, h=10, w=10)[source]¶ Generate a map with n_nodes rooms by picking a subgraph from a h,w grid.
-
textworld.generator.graph_networks.mark_doors(G, rng, possible_door_states=['open', 'closed', 'locked'])[source]¶ Put doors between neighbouring articulation points.
-
textworld.generator.graph_networks.plot_graph(g, show=True)[source]¶ Plot cartesian graph on a grid.