Commit Graph

566 Commits

Author SHA1 Message Date
BadMagic100 218f28912e
Core: Generic Entrance Rando (#2883)
* Initial implementation of Generic ER

* Move ERType to Entrance.Type, fix typing imports

* updates based on testing (read: flailing)

* Updates from feedback

* Various bug fixes in ERCollectionState

* Use deque instead of queue.Queue

* Allow partial entrances in collection state earlier, doc improvements

* Prevent early loops in region graph, improve reusability of ER stage code

* Typos, grammar, PEP8, and style "fixes"

* use RuntimeError instead of bare Exceptions

* return tuples from connect since it's slightly faster for our purposes

* move the shuffle to the beginning of find_pairing

* do er_state placements within pairing lookups to remove code duplication

* requested adjustments

* Add some temporary performance logging

* Use CollectionState to track available exits and placed regions

* Add a method to automatically disconnect entrances in a coupled-compliant way

 Update docs and cleanup todos

* Make find_placeable_exits deterministic by sorting blocked_connections set

* Move EntranceType out of Entrance

* Handle minimal accessibility, autodetect regions, and improvements to disconnect

* Add on_connect callback to react to succeeded entrance placements

* Relax island-prevention constraints after a successful run on minimal accessibility; better error message on failure

* First set of unit tests for generic ER

* Change on_connect to send lists, add unit tests for EntranceLookup

* Fix duplicated location names in tests

* Update tests after merge

* Address review feedback, start docs with diagrams

* Fix rendering of hidden nodes in ER doc

* Move most docstring content into a docs article

* Clarify when randomize_entrances can be called safely

* Address review feedback

* Apply suggestions from code review

Co-authored-by: Aaron Wagener <mmmcheese158@gmail.com>

* Docs on ERPlacementState, add coupled/uncoupled handling to deadend detection

* Documentation clarifications

* Update groups to allow any hashable

* Restrict groups from hashable to int

* Implement speculative sweeping in stage 1, address misc review comments

* Clean unused imports in BaseClasses.py

* Restrictive region/speculative sweep test

* sweep_for_events->advancement

* Remove redundant __str__

Co-authored-by: Doug Hoskisson <beauxq@users.noreply.github.com>

* Allow partial entrances in auto indirect condition sweep

* Treat regions needed for logic as non-dead-end regardless of if they have exits, flip order of stage 3 and 4 to ensure there are enough exits for the dead ends

* Typing fixes suggested by mypy

* Remove erroneous newline 

Not sure why the merge conflict editor is different and worse than the normal editor. Crazy

* Use modern typing for ER

* Enforce the use of explicit indirect conditions

* Improve doc on required indirect conditions

---------

Co-authored-by: qwint <qwint.42@gmail.com>
Co-authored-by: alwaysintreble <mmmcheese158@gmail.com>
Co-authored-by: Doug Hoskisson <beauxq@users.noreply.github.com>
2024-12-27 21:04:02 +01:00
NewSoupVi 222c8aa0ae
Core: Reword item classification definitions to allow for progression + useful (#3925)
* Core: Reword item classification definitions to allow for progression + useful

* Update network protocol.md

* Update world api.md

* Update Fill.py

* Docstrings

* Update BaseClasses.py

* Update advanced_settings_en.md

* Update advanced_settings_en.md

* Update advanced_settings_en.md

* space
2024-12-25 21:47:51 +01:00
Fabian Dill c1b27f79ac
Core: cull events from multidata spheres (#3623)
Co-authored-by: Doug Hoskisson <beauxq@users.noreply.github.com>
2024-11-30 04:11:03 +01:00
palex00 7c00c9a49d
Core: Change "Unreachable Items" to "Unreachable progression items" in playthrough warning for clarification (#4287) 2024-11-29 22:48:01 +01:00
NewSoupVi 62e4285924
Core: Make region.add_exits return the created Entrances (#3885)
* Core: Make region.add_exits return the created Entrances

* Update BaseClasses.py

* Update BaseClasses.py

Co-authored-by: Doug Hoskisson <beauxq@users.noreply.github.com>

---------

Co-authored-by: Doug Hoskisson <beauxq@users.noreply.github.com>
2024-11-29 01:41:13 +01:00
Exempt-Medic c022c742b5
Core: Add item.filler helper (#4081)
* Add filler helper

* Update BaseClasses.py
2024-11-29 01:38:53 +01:00
Mysteryem 3cb5219e09
Core: Fix playthrough only checking half of the sphere 0 items (#4268)
* Core: Fix playthrough only checking half of the sphere 0 items

The lists of precollected items were being mutated while iterating those
same lists, causing playthrough to skip checking half of the sphere 0
advancement items.

This patch ensures the lists are copied before they are iterated.

* Replace chain.from_iterable with two for loops for better clarity

Added a comment to `multiworld.push_precollected(item)` to explain that
it is also modifying `precollected_items`.
2024-11-29 01:38:17 +01:00
Fabian Dill 334781e976
Core: purge py3.8 and py3.9 (#3973)
Co-authored-by: Remy Jette <remy@remyjette.com>
Co-authored-by: Jouramie <16137441+Jouramie@users.noreply.github.com>
Co-authored-by: Aaron Wagener <mmmcheese158@gmail.com>
2024-11-27 03:28:00 +01:00
NewSoupVi a29205b547
Core: Add Item.excludable helper function (#4080)
Some worlds might want to check for "Item is junk", i.e. an excludable item.

Because this is both `filler` and `trap`, and because `filler` is `0`, there are many "wrong ways" to do this. So I think we should provide a helper function for it.
2024-11-07 09:59:08 +01:00
qwint af77b76265
Core: fix item links for alternate menu regions #4097 2024-10-26 05:59:28 +02:00
qwint e85a835b47
Core: use base collect/remove for item link groups (#3999)
* use base collect/remove for item link groups

* Update BaseClasses.py

---------

Co-authored-by: NewSoupVi <57900059+NewSoupVi@users.noreply.github.com>
2024-09-27 00:02:10 +02:00
NewSoupVi e910a37273
Core: Put an assert for parent region in Entrance.can_reach just like the one in Location.can_reach (#3998)
* Core: Move connection.parent_region assert to can_reach

This is how it already works for locations and it feels more correct to me to check in the place where the crash would happen.

Also update location error to be a bit more verbose

* Bring back the other assert

* Update BaseClasses.py
2024-09-25 17:47:38 +02:00
Silvris ce42e42af7
Core: fix single player item links (#3721)
* fix single player item links

* Make a variable and fix weird spacing

* use advancement instead of classification

---------

Co-authored-by: Exempt-Medic <60412657+Exempt-Medic@users.noreply.github.com>
2024-09-17 14:36:05 +02:00
Exempt-Medic a652108472
Docs: Update Trap classification comment #3485 2024-09-08 14:21:26 +02:00
Fabian Dill ceec51b9e1
Core: Region handling customization (#3682) 2024-09-05 16:32:45 +02:00
Doug Hoskisson 43cb9611fb
Core: some typing and cleaning in `BaseClasses.py` (#3391)
* Core: some typing and cleaning in `BaseClasses.py`

* more backwards `__repr__`

* double-quote string

* remove some end-of-line whitespace
2024-08-24 02:05:30 +02:00
NewSoupVi 64b654d42e
Core, some worlds: Rename sweep_for_events to sweep_for_advancements (#3571)
* Rename sweep_for_events to sweep_for_advancements

* more event->advancement renames

* oops accidentally deleted the deprecation thing in the force push

* Update TestDungeon.py

* Update BaseClasses.py

* Update BaseClasses.py

* oops

* utils.deprecate

* treble, you had no idea how right you were

* Update test_panel_hunt.py

* Update BaseClasses.py

Co-authored-by: Fabian Dill <Berserker66@users.noreply.github.com>

---------

Co-authored-by: Fabian Dill <Berserker66@users.noreply.github.com>
2024-08-23 01:15:05 +02:00
Mysteryem 9277cb39ef
Core: Fix incorrect default state checked in MultiWorld.can_beat_game (#3813)
`MultiWorld.can_beat_game()` with no arguments would initially check if
`self.state` is beatable, but then would create an empty state,
`state = CollectionState(self)`, to sweep spheres from to determine if
the game is beatable. The issue was that `self.state` and the new empty
state could be different.

Currently, it seems that everywhere in Archipelago's codebase that calls
`MultiWorld.can_beat_game()` with no arguments or `starting_state=None`
has a `self.state` that only contains precollected items, so the new
empty state happens to result in an equivalent state, but this should
not be relied upon to always be the case.

This patch changes `can_beat_game()` to initially check if the new empty
state is beatable instead of `self.state`.

This appears to be a bug introduced way back in 27b6dd8bd7

Fixes #3742
2024-08-19 06:44:06 +02:00
Exempt-Medic 06df072095
Core: Require excluded locations to be reachable with full/locations accessibility (#3802)
* Make excludeds reachable

* Update all_state tests
2024-08-16 20:49:37 +02:00
Aaron Wagener 96d48a923a
Core: recontextualize `CollectionState.collect` (#3723)
* Core: renamed `CollectionState.collect` arg from `event` to `prevent_sweep` and remove forced collection

* Update TestDungeon.py

---------

Co-authored-by: NewSoupVi <57900059+NewSoupVi@users.noreply.github.com>
2024-08-13 22:28:05 +02:00
Exempt-Medic dcaa2f7b97
Core: Two Small Fixes (#3782) 2024-08-13 18:02:09 +02:00
Mysteryem 30f97dd7de
Core: Speed up CollectionState.copy() using built-in copy methods (#3678)
All the types being copied are built-in types with their own `copy()`
methods, so using the `copy` module was a bit overkill and also slower.

This patch replaces the use of the `copy` module in
`CollectionState.copy()` with using the built-in `.copy()` methods.

The copying of `reachable_regions` and `blocked_connections` was also
iterating the keys of each dictionary and then looking up the value in
the dictionary for that key. It is faster, and I think more readable, to
iterate the dictionary's `.items()` instead.

For me, when generating a multiworld including the template yaml of
every world with `python -O .\Generate.py --skip_output`, this patch
saves about 2.1s. The overall generation duration for these yamls varies
quite a lot, but averages around 160s for me, so on average this patch
reduced overall generation duration (excluding output duration) by
around 1.3%.

Timing comparisons were made by calling time.perf_counter() at the start
and end of `CollectionState.copy()`'s body, and summing the differences
between the starts and ends of the method body into a global variable
that was printed at the end of generation.

Additional timing comparisons were made, using the `timeit` module, of
the individual function calls or dictionary comprehensions used to
perform the copying.

The main performance cost was `copy.deepcopy()`, which gets slow as the
number of keys multiplied by the number of values within the
sets/Counters gets large, e.g., to deepcopy a `dict[int, Counter[str]]`
with 100 keys and where each Counter contains 100 keys was 30x slower
than most other tested copying methods. Increasing the number of dict
keys or Counter keys only makes it slower.
2024-08-09 14:25:39 +02:00
Mysteryem 6e41c60672
Core: Check parent_region.can_reach first in Location.can_reach (#3724)
* Core: Check parent_region.can_reach first in Location.can_reach

The comment about self.access_rule computing faster on average appears
to no longer be correct with the current caching system for region
accessibility, resulting in self.parent_region.can_reach computing
faster on average.

Generation of template yamls for each game that does not require a rom
to generate, generated with `python -O .\Generate.py --seed 1`
(all durations averaged over at 4 or 5 generations):

Full generation with `spoiler: 1` and no progression balancing:
89.9s -> 72.6s
Only output from above case:
2.6s -> 2.2s

Full generation with `spoiler: 3` and no progression balancing:
769.9s -> 627.1s
Only playthrough calculation + paths from above case:
680.5s -> 555.3s

Full generation with `spoiler: 1` with default progression balancing:
123.5s -> 98.3s
Only progression balancing from above case:
11.3s -> 9.6s

* Update BaseClasses.py

* Update BaseClasses.py

* Update BaseClasses.py

---------

Co-authored-by: NewSoupVi <57900059+NewSoupVi@users.noreply.github.com>
2024-08-09 14:13:01 +02:00
Aaron Wagener c0ef02d6fa
Core: fix missing import for `MultiWorld.link_items()` (#3731) 2024-08-04 12:55:34 +01:00
Aaron Wagener a05dbac55f
Core: Rework accessibility (#1481)
* rename locations accessibility to "full" and make old locations accessibility debug only

* fix a bug in oot

* reorder lttp tests to not override its overrides

* changed the wrong word in the dict

* :forehead:

* update the manual lttp yaml

* use __debug__

* update pokemon and messenger

* fix conflicts from 993

* fix stardew presets

* add that locations may be inaccessible to description

* use reST format and make the items description one line so that it renders correctly on webhost

* forgot i renamed that

* add aliases for back compat

* some cleanup

* fix imports

* fix test failure

* only check "items" players when the item is progression

* Revert "only check "items" players when the item is progression"

This reverts commit ecbf986145e6194aa99a39c481d8ecd0736d5a4c.

* remove some unnecessary diffs

* CV64: Add ItemsAccessibility

* put items description at the bottom of the docstring since that's it's visual order

* :

* rename accessibility reference in pokemon rb dexsanity

* make the rendered tooltips look nicer
2024-07-31 12:13:14 +02:00
Aaron Wagener 83521e99d9
Core: migrate item links out of main (#2914)
* Core: move item linking out of main

* add a test that item link option correctly validates

* remove unused fluff

---------

Co-authored-by: NewSoupVi <57900059+NewSoupVi@users.noreply.github.com>
2024-07-31 12:04:21 +02:00
Fabian Dill b77805e5ee
Fill: remove sweep_for_events(key_only=True) (#2239) 2024-07-28 01:32:25 +02:00
NewSoupVi 61e88526cf
Core: Rename "count_exclusive" methods to "count_unique" (#3386)
* rename exclusive to unique

* lint

* group as well
2024-05-25 13:14:13 +02:00
Doug Hoskisson 230a9e620b
Core: move `OptionGroup` definition to `Options.py` (#3325) 2024-05-19 04:40:41 +02:00
Chris Wilson 5e3c5dedf3
WebHost: Massive overhaul of options pages (#2614)
* Implement support for option groups. WebHost options pages still need to be updated.

* Remove debug output

* In-progress conversion of player-options to Jinja rendering

* Support "Randomize" button without JS, transpile SCSS to CSS, include map file for later editors

* Un-alphabetize options, add default group name for item/location Option classes, implement more option types

* Re-flow UI generation to avoid printing rows with unsupported or invalid option types, add support for TextChoice options

* Support all remaining option types

* Rendering improvements and CSS fixes for prettiness

* Wrap options in a form, update button styles, fix labels, disable inputs where the default is random, nuke the JS

* Minor CSS tweaks, as recommended by the designer

* Hide JS-required elements in noscript tag. Add JS reactivity to range, named-range, and randomize buttons.

* Fix labels, add JS handling for TextChoice

* Make option groups collapsable

* PEP8 current option_groups progress (#2604)

* Make the python more PEP8 and remove unneeded imports

* remove LocationSet from `Item & Location Options` group

* It's ugly, but YAML generation is working

* Stop generating JSON files for player-options pages

* Do not include ItemDict entries whose values are zero

* Properly format yaml output

* Save options when form is submitted, load options on page load

* Fix options being omitted from the page if a group has an even number of options

* Implement generate-game, escape option descriptions

* Fix "randomize" checkboxes not properly setting YAML options to "random"

* Add a separator between item/location groups and items/locations in their respective lists

* Implement option presets

* Fix docs to detail what actually ended up happening

* implement option groups on webworld to allow dev sorting (#2616)

* Force extremely long item/location/option names with no spaces to text-wrap

* Fix "randomize" button being too wide in single-column display, change page header to include game name

* Update preset select to read "custom" when updating form inputs. Show error message if the user doesn't input a name

* Un-break weighted-options, add option group names to weighted options

* Nuke weighted-options. Set up framework to rebuild it in Jinja.

* Generate styles with scss, remove styles which will be replaced, add placeholders for worlds

* Support Toggle, DefaultOnToggle, and Choice options in weighted-options

* Implement expand/collapse without JS for worlds and option groups

* Properly style set options

* Implement Range and NamedRange. Also, CSS is hard.

* Add support for remaining option types. JS and backend still forthcoming.

* Add JS functionality for collapsing game divs, populating span values on range updates. Add <noscript> tag to warn users with JS disabled.

* Support showing/hiding game divs based on range value for game

* Add support for adding/deleting range rows

* Save settings to localStorage on form submission

* Save deleted options on form submission

* Break weighted-options into a per-game page.

- Break weighted-options into a per-game page
- Add "advanced options" links to supported games page
- Use details/summary tags on supported games, player-options, and weighted-options
- Fix bug preventing previously deleted rows from being removed on page load if JS is enabled
- Move route handling for options pages to options.py
- Remove world handling from weighted-options

* Implement loading previous settings from localStorage on page load if JS is enabled

* Weighted options can now generate YAML files and single-player games

* options pages now respect option visibility settings for simple and complex pages

* Remove `/weighted-settings` redirect, fix weighted-options link on player-options page

* Fix instance of AutoWorld not having access to proper `random`

* Catch instances of frozenset along with set

* Restore word-wrap in tooltips

* Fix word wrap in player-options labels

* Add `dedent` filter to help with formatting tooltips in player-options

* Do not change the ordering of keys when printing yaml files

* Move necessary import out of conditional statement

* Expand only the first option group by default on both options pages

* Respect option visibility when generating yaml template files

* Swap to double quotes

* Replace instances of `/weighted-settings` with `/weighted-options`, swap out incomplete links

* Strip newlines and spaces after applying dedent filter

* Fix documentation for option groups

* Update site map

* Update various docs

* Sort OptionSet lists alphabetically

* Minor style tweak

* Fix extremely long text overflowing tooltips

* Convert player-options to use CSS grid instead of tables

* Do not display link to weighted-options page on supported games if the options page is an external link

* Update worlds/AutoWorld.py

Bugfix by @alwaysintreble

Co-authored-by: Aaron Wagener <mmmcheese158@gmail.com>

* Fix NamedRange options not being properly set if a preset it loaded

* Move option-presets route into options.py

* Include preset name in YAML if not "default" and not "custom"

* Removed macros for PlandoBosses and DefaultOnToggle, as they were handled by their parent classes

* Fix not disabling custom inputs when the randomize button is clicked

* Only sort OptionList and OptionSet valid_keys if they are unordered

* Quick style fixes for player-settings to give `select` elements `text-overflow: ellipsis` and increase base size of left-column

* Prevent showing a horizontal scroll bar on player-options if the browser width was beneath a certain threshold

* Fix a bug in weighted-options which prevented inputting a negative value for new range inputs

---------

Co-authored-by: Aaron Wagener <mmmcheese158@gmail.com>
2024-05-18 00:11:57 -04:00
Exempt-Medic 5a2d839412
Removing deprecated item_count (#3309) 2024-05-17 09:54:57 +02:00
Exempt-Medic 701fbab837
Core: World: MultiWorld and another deprecated option getter (#3254)
* world: multiworld and deprecated options getting

* Oops

* Found two more
2024-05-12 18:51:20 +02:00
Trevor L d48f2ab1b4
Core: Add list/item group exclusive methods to CollectionState (#3192)
* Group exclusive methods

* Add docstrings

* Apply suggestions from code review

Co-authored-by: Doug Hoskisson <beauxq@users.noreply.github.com>

* Put lines back with no whitespace

* Add list methods

---------

Co-authored-by: Doug Hoskisson <beauxq@users.noreply.github.com>
Co-authored-by: NewSoupVi <57900059+NewSoupVi@users.noreply.github.com>
2024-05-08 18:34:32 +02:00
NewSoupVi e04db57dce
Core: Add has_list and count_list and improve (?) count_group (#2934)
* Add has_list and count_list and improve (?) count_group

* MESSENGER STOP

* Add docstrings to has_list and count_list

* Add docstrings for has_group and count_group as well

* oops

* Rename to has_from

* docstrings improvement again

* Docstring
2024-05-07 09:23:25 +02:00
NewSoupVi 0ac8844f6f
Core: Add "has_all_counts" and "has_any_count" functions to CollectionState (#2933)
* Add has_all_counts and has_any_counts

* Messenger gave me a red x and I'm mad about it

* Update BaseClasses.py

Co-authored-by: Exempt-Medic <60412657+Exempt-Medic@users.noreply.github.com>

* Update BaseClasses.py

Co-authored-by: Exempt-Medic <60412657+Exempt-Medic@users.noreply.github.com>

* Mapping instead of Dict

---------

Co-authored-by: Exempt-Medic <60412657+Exempt-Medic@users.noreply.github.com>
2024-05-07 08:15:09 +02:00
Fabian Dill 7a004de9a0
LttP: remove glitch triforce setting (#3174) 2024-04-19 23:10:29 +02:00
Fabian Dill 6e56f31398
LttP/Core: more ripping and tearing (#3160) 2024-04-18 18:33:16 +02:00
Fabian Dill 09abc5beaa
Core: add visibility attribute to Option (#3125) 2024-04-14 20:49:43 +02:00
Aaron Wagener 842a15fd3c
Core: replace `Location.event` with `advancement` property (#2871) 2024-04-14 20:37:48 +02:00
PoryGone 87b9f4a6fa
Spoiler: Display all precollected items in the Spoiler Log (#2928) 2024-04-14 20:05:16 +02:00
Alchav d4ec4d32f0
ALTTP: Bomb Walls Logic Fixes (#3130) 2024-04-14 17:30:40 +02:00
Aaron Wagener 5dcafac861
Core: add Location.is_event property (#2968) 2024-04-12 00:49:22 +02:00
Aaron Wagener c4ec8682d5
Core: fix incorrect ordering on the always_allow static method (#2938) 2024-03-12 23:29:32 +01:00
Aaron Wagener 2e1a5b0e3b
Core: create the per world random object in the world constructor (#2083)
* Core: create the per world random object in the world constructor

* remove the check that multiworld exists

* add a deprecation warning to per_slot_randoms

* move random import and fix conflicts

* assert worlds don't exist before setting the multiworld seed

* fix the dlcq and sdv tests

* actually use the seed
2024-03-10 18:47:45 +01:00
Aaron Wagener d124df72e4
Core: add specific can_reach helpers to CollectionState (#2867) 2024-03-03 17:25:21 +01:00
Aaron Wagener 8f7b0ee489
Core: don't allow region, location, or entrance with duplicate names (#2453) 2024-02-25 21:56:27 +01:00
Exempt-Medic 9f0d736aed
Generate: Fix sphere calculation debug message (#2788) 2024-02-22 09:44:03 +01:00
Alchav 7a86285807
LttP: Bombless Start and Options/Shops overhaul (#2357)
## What is this fixing or adding?
Adds Bombless Start option, along with proper bomb logic. This involves updating `can_kill_most_things` to include checking how many bombs can be held. Many places where the ability to kill enemies was assumed, now have logic. This fixes some possible existing logic issues, for example: Mini Moldorm cave checks currently are always in logic despite the fact that on expert enemy health it would require 12 bombs to kill each mini moldorm.

Overhauls options, pulling them out of core and in particular making large changes to how the shop options work.


Co-authored-by: espeon65536 <81029175+espeon65536@users.noreply.github.com>
Co-authored-by: black-sliver <59490463+black-sliver@users.noreply.github.com>
Co-authored-by: Bondo <38083232+BadmoonzZ@users.noreply.github.com>
Co-authored-by: espeon65536 <espeon65536@gmail.com>
Co-authored-by: Fabian Dill <Berserker66@users.noreply.github.com>
2024-02-20 01:07:49 +01:00
black-sliver e5980ac5f5
Core: remove module level AutoWorld import (#2790)
With BaseClasses running `worlds.__init__.py` and worlds importing
`from BaseClasses`, this is likely to result in some extra code being run
because of partial recursive imports. This now lazily loads `worlds` when
needed, at which point `sys.modules` should be properly populated.
2024-02-14 22:56:21 +01:00
Alchav 6f3bc3a7ad
Core: Minimal-Items Accessibility Fix (#1888) 2024-02-13 02:45:39 +01:00