Docs: Expanding on the answers in the FAQ (#3690)

* Expand on some existing answers

* Oops

* Sphere "one"

* Removing while

* Update docs/apworld_dev_faq.md

Co-authored-by: Scipio Wright <scipiowright@gmail.com>

---------

Co-authored-by: Scipio Wright <scipiowright@gmail.com>
This commit is contained in:
Exempt-Medic 2024-07-25 17:02:25 -04:00 committed by GitHub
parent 79843803cf
commit b6e5223aa2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 13 additions and 2 deletions

View File

@ -8,12 +8,18 @@ including [Contributing](contributing.md), [Adding Games](<adding games.md>), an
### My game has a restrictive start that leads to fill errors ### My game has a restrictive start that leads to fill errors
Hint to the Generator that an item needs to be in sphere one with local_early_items Hint to the Generator that an item needs to be in sphere one with local_early_items. Here, `1` represents the number of "Sword" items to attempt to place in sphere one.
```py ```py
early_item_name = "Sword" early_item_name = "Sword"
self.multiworld.local_early_items[self.player][early_item_name] = 1 self.multiworld.local_early_items[self.player][early_item_name] = 1
``` ```
Some alternative ways to try to fix this problem are:
* Add more locations to sphere one of your world, potentially only when there would be a restrictive start
* Pre-place items yourself, such as during `create_items`
* Put items into the player's starting inventory using `push_precollected`
* Raise an exception, such as an `OptionError` during `generate_early`, to disallow options that would lead to a restrictive start
--- ---
### I have multiple settings that change the item/location pool counts and need to balance them out ### I have multiple settings that change the item/location pool counts and need to balance them out
@ -27,8 +33,13 @@ Note: to use self.create_filler(), self.get_filler_item_name() should be defined
total_locations = len(self.multiworld.get_unfilled_locations(self.player)) total_locations = len(self.multiworld.get_unfilled_locations(self.player))
item_pool = self.create_non_filler_items() item_pool = self.create_non_filler_items()
while len(item_pool) < total_locations: for _ in range(total_locations - len(item_pool)):
item_pool.append(self.create_filler()) item_pool.append(self.create_filler())
self.multiworld.itempool += item_pool self.multiworld.itempool += item_pool
``` ```
A faster alternative to the `for` loop would be to use a [list comprehension](https://docs.python.org/3/tutorial/datastructures.html#list-comprehensions):
```py
item_pool += [self.create_filler() for _ in range(total_locations - len(item_pool))]
```