@@ -64,11 +64,6 @@ class Event:
64
64
65
65
An event gets triggered when its set of conditions become all statisfied.
66
66
67
- Attributes:
68
- actions: Actions to be performed to trigger this event
69
- commands: Human readable version of the actions.
70
- condition: :py:class:`textworld.logic.Action` that can only be applied
71
- when all conditions are statisfied.
72
67
"""
73
68
74
69
def __init__ (self , actions : Iterable [Action ] = (),
@@ -85,18 +80,23 @@ def __init__(self, actions: Iterable[Action] = (),
85
80
"""
86
81
self .actions = actions
87
82
self .commands = commands
83
+
84
+ #: :py:class:`textworld.logic.Action`: Action that can only be applied
85
+ #: when all conditions are statisfied.
88
86
self .condition = self .set_conditions (conditions )
89
87
90
88
@property
91
- def actions (self ) -> Iterable [Action ]:
89
+ def actions (self ) -> Tuple [Action ]:
90
+ """ Actions to perform to trigger this event. """
92
91
return self ._actions
93
92
94
93
@actions .setter
95
94
def actions (self , actions : Iterable [Action ]) -> None :
96
95
self ._actions = tuple (actions )
97
96
98
97
@property
99
- def commands (self ) -> Iterable [str ]:
98
+ def commands (self ) -> Tuple [str ]:
99
+ """ Human readable version of the actions. """
100
100
return self ._commands
101
101
102
102
@commands .setter
@@ -177,18 +177,6 @@ class Quest:
177
177
A quest is defined by a mutually exclusive set of winning events and
178
178
a mutually exclusive set of failing events.
179
179
180
- Attributes:
181
- win_events: Mutually exclusive set of winning events. That is,
182
- only one such event needs to be triggered in order
183
- to complete this quest.
184
- fail_events: Mutually exclusive set of failing events. That is,
185
- only one such event needs to be triggered in order
186
- to fail this quest.
187
- reward: Reward given for completing this quest.
188
- desc: A text description of the quest.
189
- commands: List of text commands leading to this quest completion.
190
- optional: Whether this quest is optional or not to finish the game.
191
- repeatable: Whether this quest can be completed more than once.
192
180
"""
193
181
194
182
def __init__ (self ,
@@ -217,13 +205,18 @@ def __init__(self,
217
205
"""
218
206
self .win_events = tuple (win_events )
219
207
self .fail_events = tuple (fail_events )
208
+
209
+ #: str: A text description of the quest.
220
210
self .desc = desc
221
211
self .commands = tuple (commands )
212
+ #: bool: Whether this quest is optional or not to finish the game.
222
213
self .optional = optional
214
+ #: bool: Whether this quest can be completed more than once.
223
215
self .repeatable = repeatable
224
216
if self .repeatable :
225
217
assert self .optional # Only optional quest can be repeatable.
226
218
219
+ #: int: Reward given for completing this quest.
227
220
# Unless explicitly provided, reward is set to 1 if there is at least
228
221
# one winning events otherwise it is set to 0.
229
222
self .reward = int (len (win_events ) > 0 ) if reward is None else reward
@@ -232,15 +225,23 @@ def __init__(self,
232
225
raise UnderspecifiedQuestError ()
233
226
234
227
@property
235
- def win_events (self ) -> Iterable [Event ]:
228
+ def win_events (self ) -> Tuple [Event ]:
229
+ """ Mutually exclusive set of winning events. That is,
230
+ only one such event needs to be triggered in order
231
+ to complete this quest.
232
+ """
236
233
return self ._win_events
237
234
238
235
@win_events .setter
239
236
def win_events (self , events : Iterable [Event ]) -> None :
240
237
self ._win_events = tuple (events )
241
238
242
239
@property
243
- def fail_events (self ) -> Iterable [Event ]:
240
+ def fail_events (self ) -> Tuple [Event ]:
241
+ """ Mutually exclusive set of failing events. That is,
242
+ only one such event needs to be triggered in order
243
+ to fail this quest.
244
+ """
244
245
return self ._fail_events
245
246
246
247
@fail_events .setter
@@ -249,6 +250,7 @@ def fail_events(self, events: Iterable[Event]) -> None:
249
250
250
251
@property
251
252
def commands (self ) -> Iterable [str ]:
253
+ """ List of text commands leading to this quest completion. """
252
254
return self ._commands
253
255
254
256
@commands .setter
@@ -297,8 +299,8 @@ def deserialize(cls, data: Mapping) -> "Quest":
297
299
def serialize (self ) -> Mapping :
298
300
""" Serialize this quest.
299
301
300
- Results :
301
- Quest's data serialized to be JSON compatible
302
+ Returns :
303
+ Quest's data serialized to be JSON compatible.
302
304
"""
303
305
data = {}
304
306
data ["desc" ] = self .desc
@@ -370,8 +372,8 @@ def deserialize(cls, data: Mapping) -> "EntityInfo":
370
372
def serialize (self ) -> Mapping :
371
373
""" Serialize this object.
372
374
373
- Results :
374
- EntityInfo's data serialized to be JSON compatible
375
+ Returns :
376
+ EntityInfo's data serialized to be JSON compatible.
375
377
"""
376
378
return {slot : getattr (self , slot ) for slot in self .__slots__ }
377
379
@@ -1071,11 +1073,6 @@ class GameOptions:
1071
1073
Number of objects in the game.
1072
1074
nb_parallel_quests (int):
1073
1075
Number of parallel quests, i.e. not sharing a common goal.
1074
- quest_length (int):
1075
- Number of actions that need to be performed to complete the game.
1076
- quest_breadth (int):
1077
- Number of subquests per independent quest. It controls how nonlinear
1078
- a quest can be (1: linear).
1079
1076
quest_depth (int):
1080
1077
Number of actions that need to be performed to solve a subquest.
1081
1078
path (str):
@@ -1086,27 +1083,6 @@ class GameOptions:
1086
1083
file_ext (str):
1087
1084
Type of the generated game file. Either .z8 (Z-Machine) or .ulx (Glulx).
1088
1085
If `path` already has an extension, this is ignored.
1089
- seeds (Optional[Union[int, Dict]]):
1090
- Seeds for the different generation processes.
1091
-
1092
- * If `None`, seeds will be sampled from
1093
- :py:data:`textworld.g_rng <textworld.utils.g_rng>`.
1094
- * If `int`, it acts as a seed for a random generator that will be
1095
- used to sample the other seeds.
1096
- * If dict, the following keys can be set:
1097
-
1098
- * `'map'`: control the map generation;
1099
- * `'objects'`: control the type of objects and their
1100
- location;
1101
- * `'quest'`: control the quest generation;
1102
- * `'grammar'`: control the text generation.
1103
-
1104
- For any key missing, a random number gets assigned (sampled
1105
- from :py:data:`textworld.g_rng <textworld.utils.g_rng>`).
1106
- kb (KnowledgeBase):
1107
- The knowledge base containing the logic and the text grammars (see
1108
- :py:class:`textworld.generator.KnowledgeBase <textworld.generator.data.KnowledgeBase>`
1109
- for more information).
1110
1086
chaining (ChainingOptions):
1111
1087
For customizing the quest generation (see
1112
1088
:py:class:`textworld.generator.ChainingOptions <textworld.generator.chaining.ChainingOptions>`
@@ -1132,6 +1108,7 @@ def __init__(self):
1132
1108
1133
1109
@property
1134
1110
def quest_length (self ) -> int :
1111
+ """ Number of actions that need to be performed to complete the game. """
1135
1112
assert self .chaining .min_length == self .chaining .max_length
1136
1113
return self .chaining .min_length
1137
1114
@@ -1143,6 +1120,9 @@ def quest_length(self, value: int) -> None:
1143
1120
1144
1121
@property
1145
1122
def quest_breadth (self ) -> int :
1123
+ """ Number of subquests per independent quest. It controls how nonlinear
1124
+ a quest can be (1 means linear).
1125
+ """
1146
1126
assert self .chaining .min_breadth == self .chaining .max_breadth
1147
1127
return self .chaining .min_breadth
1148
1128
@@ -1153,6 +1133,23 @@ def quest_breadth(self, value: int) -> None:
1153
1133
1154
1134
@property
1155
1135
def seeds (self ):
1136
+ """ Seeds for the different generation processes.
1137
+
1138
+ * If `None`, seeds will be sampled from
1139
+ :py:data:`textworld.g_rng <textworld.utils.g_rng>`.
1140
+ * If `int`, it acts as a seed for a random generator that will be
1141
+ used to sample the other seeds.
1142
+ * If dict, the following keys can be set:
1143
+
1144
+ * `'map'`: control the map generation;
1145
+ * `'objects'`: control the type of objects and their
1146
+ location;
1147
+ * `'quest'`: control the quest generation;
1148
+ * `'grammar'`: control the text generation.
1149
+
1150
+ For any key missing, a random number gets assigned (sampled
1151
+ from :py:data:`textworld.g_rng <textworld.utils.g_rng>`).
1152
+ """
1156
1153
if self ._seeds is None :
1157
1154
self .seeds = {} # Generate seeds from g_rng.
1158
1155
@@ -1190,6 +1187,10 @@ def rngs(self) -> Dict[str, RandomState]:
1190
1187
1191
1188
@property
1192
1189
def kb (self ) -> KnowledgeBase :
1190
+ """ The knowledge base containing the logic and the text grammars (see
1191
+ :py:class:`textworld.generator.KnowledgeBase <textworld.generator.data.KnowledgeBase>`
1192
+ for more information).
1193
+ """
1193
1194
if self ._kb is None :
1194
1195
self .kb = KnowledgeBase .load ()
1195
1196
0 commit comments