* initial commit of rules engine
* implement most of the stuff
* add docs and fill out rest of the functionality
* add in explain functions
* dedupe items and add more docs
* pr feedback and optimization updates
* Self is not in typing on 3.10
* fix test
* Update docs/rule builder.md
Co-authored-by: BadMagic100 <dempsey.sean@outlook.com>
* pr feedback
* love it when CI gives me different results than local
* add composition with bitwise and and or
* strongly typed option filtering
* skip resolving location parent region
* update docs
* update typing and add decorator
* add string explains
* move simplify code to world
* add wrapper rule
* I may need to abandon the generic typing
* missing space for faris
* fix hashing for resolved rules
* thank u typing extensions ilu
* remove bad cacheable check
* add decorator to assign hash and rule name
* more type crimes...
* region access rules are now cached
* break compatibility so new features work
* update docs
* replace decorators with __init_subclass__
* ok now the frozen dataclass is automatic
* one more type fix for the road
* small fixes and caching tests
* play nicer with tests
* ok actually fix the tests
* add item_mapping for faris
* add more state helpers as rules
* fix has from list rules
* fix can reach location caching and add set completion condition
* fix can reach entrance caching
* implement HasGroup and HasGroupUnique
* add more tests and fix some bugs
* Add name arg to create_entrance
Co-authored-by: roseasromeo <11944660+roseasromeo@users.noreply.github.com>
* fix json dumping option filters
* restructure and test serialization
* add prop to disable caching
* switch to __call__ and revert access_rule changes
* update docs and make edge cases match
* ruff has lured me into a false sense of security
* also unused
* fix disabling caching
* move filter function to filter class
* add more docs
* tests for explain functions
* Update docs/rule builder.md
Co-authored-by: roseasromeo <11944660+roseasromeo@users.noreply.github.com>
* chore: Strip out uses of TYPE_CHECKING as much as possible
* chore: add empty webworld for test
* chore: optimize rule evaluations
* remove getattr from hot code paths
* testing new cache flags
* only clear cache for rules cached as false in collect
* update test for new behaviour
* do not have rules inherit from each other
* update docs on caching
* fix name of attribute
* make explain messages more colorful
* fix issue with combining rules with different options
* add convenience functions for filtering
* use an operator with higher precedence
* name conflicts less with optionfilter
* move simplify and instance caching code
* update docs
* kill resolve_rule
* kill true_rule and false_rule
* move helpers to base classes
* update docs
* I really should finish all of my
* fix test
* rename mixin
* fix typos
* refactor rule builder into folder for better imports
* update docs
* do not dupe collectionrule
* docs review feedback
* missed a file
* remove rule_caching_enabled from base World
* update docs on caching
* shuffle around some docs
* use option instead of option.value
* add in operator and more testing
* rm World = object
* test fixes
* move cache to logic mixin
* keep test rule builder world out of global registry
* todone
* call register_dependencies automatically
* move register deps call to call_single
* add filtered_resolution
* allow bool opts on filters
* fix serialization tests
* allow reverse operations
---------
Co-authored-by: BadMagic100 <dempsey.sean@outlook.com>
Co-authored-by: roseasromeo <11944660+roseasromeo@users.noreply.github.com>
* Test: check game in world manifest
* Update test/general/test_world_manifest.py
Co-authored-by: Duck <31627079+duckboycool@users.noreply.github.com>
* Test: rework finding expected manifest location
* Test: fix doc comment
* Test: fix wrong custom_worlds path in test_world_manifest
Also simplifies the way we find ./worlds/.
* Test: make test_world_manifest easier to extend
* Test: check world_version in world manifest
according to docs/apworld specification.md
* Test: check no container version in source world manifest
according what was added to docs/apworld specification.md in PR 5509
* Test: better assertion messages in test_world_manifest.py
* Test: fix wording in world source manifest
---------
Co-authored-by: Duck <31627079+duckboycool@users.noreply.github.com>
* Add new deprioritized item flag
* 4 retries
* indent
* .
* style
* I think this is nicer
* Nicer
* remove two lines again that I added unnecessarily
* I think this test makes a bit more sense like this
* Idk how to word this lol
* Add progression_deprioritized_skip_balancing bc why not ig
* More text
* Update Fill.py
* Update Fill.py
* I am the big stupid
* Actually collect the other half of progression items into state when filling without them
* More clarity on the descriptions (hopefully)
* visually separate technical description and use cases
* Actually make the call do what the comments say it does
* Only consider usable exits when calculating whether or not a region is a dead-end
* Update EntranceLookup unit tests
* Add new dead-end test
* Add additional explanation to the new test
* minor formatting tweak
based on review feedback
---------
Co-authored-by: CodeGorilla <3672561+Ars-Ignis@users.noreply.github.com>
* [Core][GER] Allow and require user-provided target name when splitting 1-way entrances
* Move target naming onto a parameter of disconnect_entrance_for_randomization
* Add test that stage1 ER will not fail due to speculative sweeping an indirect conditioned dead end
* Skip speculative sweep if it's the last entrance placement
* Better implementation of needs_speculative_sweep
* pep8
* uses itempool count vs unfilled location count instead of counting prog_items values which could have custom counters
* move unfilled location check to before can_reach
* add tests for successful minimal GER call with extra collect override prog_items in the pool to regression test issue fixed in this PR
* Tests: massively improve the memory leak test performance
With the growing number of worlds, GC becomes the bottleneck and slows down the test.
* Tests: fix typing in general/test_memory
* unit test that get all state is called with partial entrances before connect_entrances
* fix the two worlds doing it
* lol
* unused import
* Update test/general/test_entrances.py
Co-authored-by: Exempt-Medic <60412657+Exempt-Medic@users.noreply.github.com>
* Update test_entrances.py
---------
Co-authored-by: Exempt-Medic <60412657+Exempt-Medic@users.noreply.github.com>
* Add connect_entrances
* update ER docs
* fix that test, but also ew
* Add a test that asserts the new finalization
* Rewrite test a bit
* rewrite some more
* blank line
* rewrite rewrite rewrite
* rewrite rewrite rewrite
* RE. WRITE.
* oops
* Bruh
* I guess, while we're at it
* giga oops
* It's been a long day
* Switch KH1 over to this design with permission of GICU
* Revert
* Oops
* Bc I like it
* Update locations.py
* Core: some low-hanging fruit on the strict type check
* bump pyright version
* bump pyright version
* bump pyright and remove file that's no longer easy
* 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>
* Core: fix settings API for removal of Python 3.8, 3.9
This is fixing 2 problems:
- The `World` class has the annotation:
`settings: ClassVar[Optional["Group"]]`
so `MyWorld.settings` should not raise an exception like it does for some worlds.
With the `Optional` there, it looks like it should return `None` for the worlds that don't use it. So that's what I changed it to.
- `Group.update` had some code that required `typing.Union` instead of the Python 3.10 `|` for unions.
added unit test for this fix
added change in Zillion that I used to discover this problem and used it to test the test
* fix copy-pasted stuff
* tuple instead of set
Co-authored-by: black-sliver <59490463+black-sliver@users.noreply.github.com>
---------
Co-authored-by: black-sliver <59490463+black-sliver@users.noreply.github.com>
* 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>