Skip to content

Commit d92d14e

Browse files
committed
Fix documentation
1 parent eba79ae commit d92d14e

File tree

5 files changed

+61
-61
lines changed

5 files changed

+61
-61
lines changed

docs/requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
-r ../requirements.txt
2-
sphinx>=2
2+
sphinx>=2,<=5.1.1
33
recommonmark
44
sphinx_autodoc_typehints
55
sphinx-argparse
6-
-e git://github.com/snide/sphinx_rtd_theme.git#egg=sphinx_rtd_theme
6+
sphinx-rtd-theme

docs/source/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
#
7979
# This is also used if you do content translation via gettext catalogs.
8080
# Usually you set "language" from the command line for these cases.
81-
language = None
81+
language = 'en'
8282

8383
# List of patterns, relative to source directory, that match files and
8484
# directories to ignore when looking for source files.
@@ -106,7 +106,7 @@
106106
# Add any paths that contain custom static files (such as style sheets) here,
107107
# relative to this directory. They are copied after the builtin static files,
108108
# so a file named "default.css" will overwrite the builtin "default.css".
109-
html_static_path = ['_static']
109+
# html_static_path = ['_static']
110110

111111
# Custom sidebar templates, must be a dictionary that maps document names
112112
# to template names.

docs/source/notes/zork1.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ Some notes about Zork1.
33

44
## Stochasticity
55
Zork1 has some stochasticity in it:
6-
- the thief will wander randomly in the dungeon stealing stuff.
7-
- when attacking someone, you can miss (to confirm)
6+
7+
- the thief will wander randomly in the dungeon stealing stuff.
8+
- when attacking someone, you can miss (to confirm)
89

910
## Death
1011
It seems that when you died, you get to continue playing but you lose 10 points (I think it is always 10). However, on your third death, the game ends.

textworld/generator/chaining.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,9 @@ class ChainingOptions:
8989
Whether to allow totally independent parallel chains.
9090
create_variables:
9191
Whether new variables may be created during chaining.
92-
fixed_mapping:
93-
A fixed mapping from placeholders to variables, for singletons.
9492
rng:
9593
If provided, randomize the order of the quests using this random
9694
number generator.
97-
logic:
98-
The rules of the game.
9995
rules_per_depth:
10096
A list of lists of rules for restricting the allowed actions at
10197
certain depths.
@@ -124,10 +120,12 @@ def __init__(self):
124120

125121
@property
126122
def logic(self) -> GameLogic:
123+
""" The rules of the game. """
127124
return self.kb.logic
128125

129126
@property
130127
def fixed_mapping(self) -> GameLogic:
128+
""" A fixed mapping from placeholders to variables, for singletons. """
131129
return self.kb.types.constants_mapping
132130

133131
def get_rules(self, depth: int) -> Iterable[Rule]:

textworld/generator/game.py

Lines changed: 52 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,6 @@ class Event:
6464
6565
An event gets triggered when its set of conditions become all statisfied.
6666
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.
7267
"""
7368

7469
def __init__(self, actions: Iterable[Action] = (),
@@ -85,18 +80,23 @@ def __init__(self, actions: Iterable[Action] = (),
8580
"""
8681
self.actions = actions
8782
self.commands = commands
83+
84+
#: :py:class:`textworld.logic.Action`: Action that can only be applied
85+
#: when all conditions are statisfied.
8886
self.condition = self.set_conditions(conditions)
8987

9088
@property
91-
def actions(self) -> Iterable[Action]:
89+
def actions(self) -> Tuple[Action]:
90+
""" Actions to perform to trigger this event. """
9291
return self._actions
9392

9493
@actions.setter
9594
def actions(self, actions: Iterable[Action]) -> None:
9695
self._actions = tuple(actions)
9796

9897
@property
99-
def commands(self) -> Iterable[str]:
98+
def commands(self) -> Tuple[str]:
99+
""" Human readable version of the actions. """
100100
return self._commands
101101

102102
@commands.setter
@@ -177,18 +177,6 @@ class Quest:
177177
A quest is defined by a mutually exclusive set of winning events and
178178
a mutually exclusive set of failing events.
179179
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.
192180
"""
193181

194182
def __init__(self,
@@ -217,13 +205,18 @@ def __init__(self,
217205
"""
218206
self.win_events = tuple(win_events)
219207
self.fail_events = tuple(fail_events)
208+
209+
#: str: A text description of the quest.
220210
self.desc = desc
221211
self.commands = tuple(commands)
212+
#: bool: Whether this quest is optional or not to finish the game.
222213
self.optional = optional
214+
#: bool: Whether this quest can be completed more than once.
223215
self.repeatable = repeatable
224216
if self.repeatable:
225217
assert self.optional # Only optional quest can be repeatable.
226218

219+
#: int: Reward given for completing this quest.
227220
# Unless explicitly provided, reward is set to 1 if there is at least
228221
# one winning events otherwise it is set to 0.
229222
self.reward = int(len(win_events) > 0) if reward is None else reward
@@ -232,15 +225,23 @@ def __init__(self,
232225
raise UnderspecifiedQuestError()
233226

234227
@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+
"""
236233
return self._win_events
237234

238235
@win_events.setter
239236
def win_events(self, events: Iterable[Event]) -> None:
240237
self._win_events = tuple(events)
241238

242239
@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+
"""
244245
return self._fail_events
245246

246247
@fail_events.setter
@@ -249,6 +250,7 @@ def fail_events(self, events: Iterable[Event]) -> None:
249250

250251
@property
251252
def commands(self) -> Iterable[str]:
253+
""" List of text commands leading to this quest completion. """
252254
return self._commands
253255

254256
@commands.setter
@@ -297,8 +299,8 @@ def deserialize(cls, data: Mapping) -> "Quest":
297299
def serialize(self) -> Mapping:
298300
""" Serialize this quest.
299301
300-
Results:
301-
Quest's data serialized to be JSON compatible
302+
Returns:
303+
Quest's data serialized to be JSON compatible.
302304
"""
303305
data = {}
304306
data["desc"] = self.desc
@@ -370,8 +372,8 @@ def deserialize(cls, data: Mapping) -> "EntityInfo":
370372
def serialize(self) -> Mapping:
371373
""" Serialize this object.
372374
373-
Results:
374-
EntityInfo's data serialized to be JSON compatible
375+
Returns:
376+
EntityInfo's data serialized to be JSON compatible.
375377
"""
376378
return {slot: getattr(self, slot) for slot in self.__slots__}
377379

@@ -1071,11 +1073,6 @@ class GameOptions:
10711073
Number of objects in the game.
10721074
nb_parallel_quests (int):
10731075
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).
10791076
quest_depth (int):
10801077
Number of actions that need to be performed to solve a subquest.
10811078
path (str):
@@ -1086,27 +1083,6 @@ class GameOptions:
10861083
file_ext (str):
10871084
Type of the generated game file. Either .z8 (Z-Machine) or .ulx (Glulx).
10881085
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).
11101086
chaining (ChainingOptions):
11111087
For customizing the quest generation (see
11121088
:py:class:`textworld.generator.ChainingOptions <textworld.generator.chaining.ChainingOptions>`
@@ -1132,6 +1108,7 @@ def __init__(self):
11321108

11331109
@property
11341110
def quest_length(self) -> int:
1111+
""" Number of actions that need to be performed to complete the game. """
11351112
assert self.chaining.min_length == self.chaining.max_length
11361113
return self.chaining.min_length
11371114

@@ -1143,6 +1120,9 @@ def quest_length(self, value: int) -> None:
11431120

11441121
@property
11451122
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+
"""
11461126
assert self.chaining.min_breadth == self.chaining.max_breadth
11471127
return self.chaining.min_breadth
11481128

@@ -1153,6 +1133,23 @@ def quest_breadth(self, value: int) -> None:
11531133

11541134
@property
11551135
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+
"""
11561153
if self._seeds is None:
11571154
self.seeds = {} # Generate seeds from g_rng.
11581155

@@ -1190,6 +1187,10 @@ def rngs(self) -> Dict[str, RandomState]:
11901187

11911188
@property
11921189
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+
"""
11931194
if self._kb is None:
11941195
self.kb = KnowledgeBase.load()
11951196

0 commit comments

Comments
 (0)