Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
207 commits
Select commit Hold shift + click to select a range
0018d2f
initial commit of rules engine
drtchops May 21, 2025
2d4ef18
implement most of the stuff
drtchops May 23, 2025
ee575e9
add docs and fill out rest of the functionality
drtchops May 26, 2025
298ffb5
Merge branch 'main' into rules-engine
drtchops May 26, 2025
da19a1b
add in explain functions
drtchops May 26, 2025
4b565ce
dedupe items and add more docs
drtchops May 26, 2025
77b8708
Merge branch 'main' into rules-engine
drtchops Jun 8, 2025
cae61e9
pr feedback and optimization updates
drtchops Jun 9, 2025
74472cd
Self is not in typing on 3.10
drtchops Jun 9, 2025
e770532
fix test
drtchops Jun 9, 2025
c25079e
Update docs/rule builder.md
drtchops Jun 9, 2025
bb75c3e
pr feedback
drtchops Jun 9, 2025
be39be5
love it when CI gives me different results than local
drtchops Jun 9, 2025
f74c074
add composition with bitwise and and or
drtchops Jun 11, 2025
873af53
strongly typed option filtering
drtchops Jun 11, 2025
0fd5796
skip resolving location parent region
drtchops Jun 12, 2025
b45a716
update docs
drtchops Jun 15, 2025
b763e03
Merge branch 'main' into rules-engine
drtchops Jun 15, 2025
41c3346
Merge branch 'rules-engine' into astalon-rule-builder
drtchops Jun 15, 2025
14bc8ac
start conversion to new rule builder
drtchops Jun 15, 2025
e749b4d
update tests
drtchops Jun 15, 2025
e646a72
update typing and add decorator
drtchops Jun 16, 2025
985d545
add string explains
drtchops Jun 16, 2025
39221ff
start conversion to rule builder
drtchops Jun 16, 2025
bca4c85
Merge branch 'rules-engine' of github.com:drtchops/Archipelago into a…
drtchops Jun 16, 2025
7f150f2
move simplify code to world
drtchops Jun 16, 2025
b48a60c
add wrapper rule
drtchops Jun 16, 2025
f398865
I may need to abandon the generic typing
drtchops Jun 16, 2025
aaab077
Merge branch 'rules-engine' of github.com:drtchops/Archipelago into a…
drtchops Jun 16, 2025
58f2c1b
missing space for faris
drtchops Jun 16, 2025
44d91ec
fix hashing for resolved rules
drtchops Jun 16, 2025
1fb706f
thank u typing extensions ilu
drtchops Jun 16, 2025
1cb9e03
remove bad cacheable check
drtchops Jun 16, 2025
4a4b147
update
drtchops Jun 16, 2025
3e91832
Merge branch 'rules-engine' of github.com:drtchops/Archipelago into a…
drtchops Jun 16, 2025
9efa79c
once more update to latest rule builder api
drtchops Jun 16, 2025
1b9c5c5
add decorator to assign hash and rule name
drtchops Jun 16, 2025
61da285
more type crimes...
drtchops Jun 16, 2025
730d9ec
region access rules are now cached
drtchops Jun 16, 2025
a90cb9c
Merge branch 'rules-engine' of github.com:drtchops/Archipelago into a…
drtchops Jun 16, 2025
ad07a4c
break compatibility so new features work
drtchops Jun 16, 2025
1ff33c8
update to new api
drtchops Jun 16, 2025
18f52ca
Merge branch 'rules-engine' of github.com:drtchops/Archipelago into a…
drtchops Jun 16, 2025
41a0496
update docs
drtchops Jun 17, 2025
b0af7a1
replace decorators with __init_subclass__
drtchops Jun 18, 2025
336658f
ok now the frozen dataclass is automatic
drtchops Jun 18, 2025
78cd548
Merge branch 'rules-engine' of github.com:drtchops/Archipelago into a…
drtchops Jun 18, 2025
83a4465
update to latest api
drtchops Jun 18, 2025
fd811f6
one more type fix for the road
drtchops Jun 18, 2025
ce02c76
Merge branch 'rules-engine' of github.com:drtchops/Archipelago into a…
drtchops Jun 18, 2025
348c9bf
type param no longer needed
drtchops Jun 18, 2025
2233329
small fixes and caching tests
drtchops Jun 21, 2025
c7a30d9
play nicer with tests
drtchops Jun 21, 2025
afbd089
ok actually fix the tests
drtchops Jun 21, 2025
b558452
Merge branch 'main' into rules-engine
drtchops Jun 21, 2025
59e6ab6
Merge branch 'rules-engine' of github.com:drtchops/Archipelago into a…
drtchops Jun 21, 2025
9ad1245
add item_mapping for faris
drtchops Jun 21, 2025
0ff085a
add more state helpers as rules
drtchops Jun 22, 2025
71d5fb3
fix has from list rules
drtchops Jun 22, 2025
8484f63
fix can reach location caching and add set completion condition
drtchops Jun 25, 2025
f432c08
Merge branch 'rules-engine' of github.com:drtchops/Archipelago into a…
drtchops Jun 25, 2025
9dca0ba
update api
drtchops Jun 25, 2025
d07e6c4
fix import
drtchops Jun 25, 2025
1c669ec
also update client
drtchops Jun 25, 2025
1e58bc4
fix can reach entrance caching
drtchops Jun 26, 2025
29c7ac8
Merge branch 'main' into rules-engine
drtchops Jun 26, 2025
1e9adf3
implement HasGroup and HasGroupUnique
drtchops Jun 26, 2025
03878cf
add more tests and fix some bugs
drtchops Jun 26, 2025
072959b
Add name arg to create_entrance
drtchops Jun 27, 2025
4bc1e06
fix json dumping option filters
drtchops Jun 29, 2025
f5f03ff
restructure and test serialization
drtchops Jul 1, 2025
28d4edc
add prop to disable caching
drtchops Jul 8, 2025
4a5436e
switch to __call__ and revert access_rule changes
drtchops Jul 8, 2025
a916cd5
Merge branch 'main' into rules-engine
drtchops Jul 8, 2025
0a8099a
update docs and make edge cases match
drtchops Jul 8, 2025
e8c5569
ruff has lured me into a false sense of security
drtchops Jul 8, 2025
5ce1e70
also unused
drtchops Jul 8, 2025
0e4270d
Merge branch 'rules-engine' of github.com:drtchops/Archipelago into a…
drtchops Jul 8, 2025
a62156f
update rule builder
drtchops Jul 8, 2025
afee42a
fix disabling caching
drtchops Jul 9, 2025
d429945
Merge branch 'rules-engine' of github.com:drtchops/Archipelago into a…
drtchops Jul 9, 2025
a877b0b
fix test
drtchops Jul 9, 2025
457e233
Merge branch 'main' into rules-engine
drtchops Jul 13, 2025
083b9c7
move filter function to filter class
drtchops Jul 13, 2025
04763cb
Merge branch 'main' into rules-engine
drtchops Jul 23, 2025
f9641c1
add more docs
drtchops Jul 23, 2025
66e3841
tests for explain functions
drtchops Jul 23, 2025
56432bf
Update docs/rule builder.md
drtchops Aug 2, 2025
19b858e
chore: Strip out uses of TYPE_CHECKING as much as possible
drtchops Aug 2, 2025
a87533b
Merge branch 'main' into rules-engine
drtchops Aug 2, 2025
9f17acd
Merge branch 'main' into rules-engine
drtchops Aug 24, 2025
ad16c3a
Merge branch 'rules-engine' into astalon-rule-builder
drtchops Aug 24, 2025
d92ae3a
Merge branch 'astalon' into astalon-rule-builder
drtchops Aug 24, 2025
5b8283f
Merge branch 'astalon' into astalon-rule-builder
drtchops Aug 24, 2025
ff22e7b
chore: add empty webworld for test
drtchops Aug 24, 2025
edea764
Merge branch 'rules-engine' into astalon-rule-builder
drtchops Aug 24, 2025
3a9591a
Merge branch 'main' into rules-engine
drtchops Sep 1, 2025
d1499ff
Merge branch 'astalon' into astalon-rule-builder
drtchops Sep 1, 2025
012a5b7
Merge branch 'rules-engine' into astalon-rule-builder
drtchops Sep 1, 2025
2a6eede
fix rules when caching is disabled
drtchops Sep 2, 2025
35b95eb
chore: optimize rule evaluations
drtchops Sep 4, 2025
27f72d0
Merge branch 'main' into rules-engine
drtchops Sep 9, 2025
69a43d0
remove getattr from hot code paths
drtchops Sep 9, 2025
fcb68fa
testing new cache flags
drtchops Sep 14, 2025
8b69e68
Merge branch 'main' into rules-engine
drtchops Sep 18, 2025
ff65610
only clear cache for rules cached as false in collect
drtchops Sep 18, 2025
9ad456b
Merge branch 'rules-engine' into astalon-rule-builder
drtchops Sep 18, 2025
a0ff983
update test for new behaviour
drtchops Sep 18, 2025
498dde6
fix custom rules
drtchops Sep 19, 2025
ad42a91
do not have rules inherit from each other
drtchops Sep 20, 2025
7c85680
update docs on caching
drtchops Sep 20, 2025
30a1ee8
Merge branch 'main' into rules-engine
drtchops Sep 20, 2025
667231a
Merge branch 'main' into rules-engine
drtchops Sep 21, 2025
f0ef2fe
Merge branch 'astalon' into astalon-rule-builder
drtchops Sep 21, 2025
7d8c7f6
fix latest astalon updates
drtchops Sep 21, 2025
fcb987a
Merge branch 'rules-engine' into astalon-rule-builder
drtchops Sep 21, 2025
00f3222
start converting rules to new format
drtchops Sep 29, 2025
ab59a75
Merge branch 'astalon' into astalon-rule-builder
drtchops Sep 29, 2025
823f14b
Merge branch 'main' of github.com:ArchipelagoMW/Archipelago into rule…
drtchops Sep 29, 2025
660069b
fix name of attribute
drtchops Sep 29, 2025
7cf0338
make explain messages more colorful
drtchops Sep 29, 2025
d3888ad
Merge branch 'main' of github.com:ArchipelagoMW/Archipelago into rule…
drtchops Oct 7, 2025
d85f1f1
Merge branch 'rules-engine' into astalon-rule-builder
drtchops Oct 7, 2025
91d080b
Merge branch 'main' of github.com:ArchipelagoMW/Archipelago into rule…
drtchops Oct 19, 2025
b240d71
Merge branch 'main' into rules-engine
drtchops Nov 9, 2025
69bb6c7
Merge branch 'rules-engine' into astalon-rule-builder
drtchops Nov 9, 2025
599b224
refactor all the rules
drtchops Nov 17, 2025
7198ab9
Merge branch 'main' into rules-engine
drtchops Nov 17, 2025
c631a94
Merge branch 'astalon' into astalon-rule-builder
drtchops Nov 17, 2025
46af354
Merge branch 'rules-engine' into astalon-rule-builder
drtchops Nov 17, 2025
bb79dcc
fix issue with combining rules with different options
drtchops Nov 18, 2025
f98643d
Merge branch 'rules-engine' into astalon-rule-builder
drtchops Nov 18, 2025
393e03c
fix test
drtchops Nov 18, 2025
2612cca
Merge branch 'main' into rules-engine
drtchops Nov 21, 2025
59653f0
add convenience functions for filtering
drtchops Nov 21, 2025
dad814e
Merge branch 'rules-engine' into astalon-rule-builder
drtchops Nov 21, 2025
76e28cd
use an operator with higher precedence
drtchops Nov 21, 2025
245cf7b
Merge branch 'rules-engine' into astalon-rule-builder
drtchops Nov 21, 2025
a4732db
name conflicts less with optionfilter
drtchops Nov 21, 2025
1e5709b
Merge branch 'rules-engine' into astalon-rule-builder
drtchops Nov 21, 2025
54bff88
update to use filter helpers
drtchops Nov 21, 2025
9df619d
kill off TYPE_CHECKING by any means necessary
drtchops Nov 25, 2025
47cf037
Merge branch 'main' into rules-engine
drtchops Nov 25, 2025
1cdf5c5
Merge branch 'astalon' into astalon-rule-builder
drtchops Nov 25, 2025
c952fd9
Merge branch 'rules-engine' into astalon-rule-builder
drtchops Nov 25, 2025
07aaefa
get ready for v1
drtchops Nov 25, 2025
42af4ee
add missing height check
drtchops Nov 26, 2025
3da27c6
Merge branch 'main' into rules-engine
drtchops Dec 10, 2025
765cebb
Merge branch 'astalon' into astalon-rule-builder
drtchops Dec 10, 2025
7babffa
Merge branch 'rules-engine' into astalon-rule-builder
drtchops Dec 10, 2025
014f1aa
move simplify and instance caching code
drtchops Dec 11, 2025
9cba001
Merge branch 'main' into rules-engine
drtchops Dec 11, 2025
aa26195
update docs
drtchops Dec 12, 2025
bd75699
kill resolve_rule
drtchops Dec 12, 2025
0706b44
kill true_rule and false_rule
drtchops Dec 12, 2025
9a196e9
move helpers to base classes
drtchops Dec 12, 2025
d900963
Merge branch 'astalon' into astalon-rule-builder
drtchops Dec 12, 2025
ab4b783
Merge branch 'rules-engine' into astalon-rule-builder
drtchops Dec 12, 2025
bd0cf0e
fix compat
drtchops Dec 12, 2025
a6cbe07
fix import
drtchops Dec 12, 2025
dd63d31
update docs
drtchops Dec 12, 2025
11b4e66
I really should finish all of my
drtchops Dec 12, 2025
8597fc1
fix test
drtchops Dec 12, 2025
3fc8769
rename mixin
drtchops Dec 12, 2025
71ed8c5
fix typos
drtchops Dec 12, 2025
c0414b6
Merge branch 'main' into rules-engine
drtchops Dec 24, 2025
632aa22
refactor rule builder into folder for better imports
drtchops Dec 25, 2025
9b1062f
update docs
drtchops Dec 25, 2025
01a1b25
do not dupe collectionrule
drtchops Dec 28, 2025
93ec569
Merge branch 'main' into rules-engine
drtchops Dec 28, 2025
773fce0
docs review feedback
drtchops Dec 28, 2025
6ab758a
missed a file
drtchops Dec 28, 2025
ed38f48
remove rule_caching_enabled from base World
drtchops Dec 30, 2025
f10415a
update docs on caching
drtchops Dec 30, 2025
0498ea6
shuffle around some docs
drtchops Dec 30, 2025
ae4db8c
Merge branch 'astalon' into astalon-rule-builder
drtchops Dec 30, 2025
f2fb10e
Merge branch 'rules-engine' into astalon-rule-builder
drtchops Dec 30, 2025
5275bfd
fix merge
drtchops Dec 30, 2025
e3678bf
rm old test
drtchops Dec 30, 2025
1e76dfb
Merge branch 'main' into rules-engine
drtchops Jan 14, 2026
fc45650
use option instead of option.value
drtchops Jan 14, 2026
5fff1c5
add in operator and more testing
drtchops Jan 14, 2026
7c76099
rm World = object
drtchops Jan 14, 2026
e6e0e1b
test fixes
drtchops Jan 14, 2026
ee1c593
move cache to logic mixin
drtchops Jan 14, 2026
0217619
keep test rule builder world out of global registry
drtchops Jan 15, 2026
f0a44b9
Merge branch 'rules-engine' into astalon-rule-builder
drtchops Jan 15, 2026
8c22c57
Merge branch 'astalon' into astalon-rule-builder
drtchops Jan 15, 2026
05b8021
fix OptionFilter compat
drtchops Jan 15, 2026
623ce10
todone
drtchops Jan 15, 2026
f011323
Merge branch 'main' into rules-engine
drtchops Feb 2, 2026
02559d3
call register_dependencies automatically
drtchops Feb 2, 2026
a5ccc9d
Merge branch 'main' into rules-engine
drtchops Feb 7, 2026
bfb6619
move register deps call to call_single
drtchops Feb 7, 2026
63fa169
add filtered_resolution
drtchops Feb 7, 2026
138a429
allow bool opts on filters
drtchops Feb 7, 2026
d4aadb6
fix serialization tests
drtchops Feb 7, 2026
1ec0a87
Merge branch 'rules-engine' into astalon-rule-builder
drtchops Feb 7, 2026
1741bbc
Merge branch 'astalon' into astalon-rule-builder
drtchops Feb 7, 2026
b9f5c44
no more shovel
drtchops Feb 7, 2026
2d549f7
Merge branch 'astalon' into astalon-rule-builder
drtchops Feb 8, 2026
7dc86fa
no longer needed
drtchops Feb 8, 2026
2f935cd
clean up default rules
drtchops Feb 9, 2026
c0fe76a
add some missing rules
drtchops Feb 9, 2026
03774ee
forgot the most important change
drtchops Feb 9, 2026
78dfd2d
do not use cached world I guess
drtchops Feb 9, 2026
4b7b5fe
fix removing caching
drtchops Feb 9, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 3 additions & 21 deletions worlds/astalon/bases.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,14 @@
from abc import ABCMeta
from collections import defaultdict
from typing import TYPE_CHECKING, Any, ClassVar
from typing import ClassVar

from BaseClasses import MultiWorld
from worlds.AutoWorld import AutoWorldRegister, World
from worlds.AutoWorld import World

from .items import Character, EarlyItems
from .options import AstalonOptions
from .settings import AstalonSettings

if TYPE_CHECKING:
from .logic.instances import RuleInstance


# TODO: remove once ap 0.6.6 is released
class AstalonWorldMetaclass(AutoWorldRegister, ABCMeta):
def __new__(mcs, name: str, bases: tuple[type, ...], dct: dict[str, Any]) -> AutoWorldRegister:
if name == "AstalonWorld":
return super().__new__(mcs, name, bases, dct)
return super(AutoWorldRegister, mcs).__new__(mcs, name, bases, dct)


class AstalonWorldBase(World, metaclass=AstalonWorldMetaclass):
class AstalonWorldBase(World):
options_dataclass = AstalonOptions
settings: ClassVar[AstalonSettings] # pyright: ignore[reportIncompatibleVariableOverride]

Expand All @@ -31,12 +18,7 @@ class AstalonWorldBase(World, metaclass=AstalonWorldMetaclass):
early_items: EarlyItems
portal_pairs: tuple[tuple[str, str], ...] = ()

rule_cache: "dict[int, RuleInstance]"
_rule_deps: dict[str, set[int]]

def __init__(self, multiworld: MultiWorld, player: int) -> None:
super().__init__(multiworld, player)
self.starting_characters = []
self.early_items = EarlyItems()
self.rule_cache = {}
self._rule_deps = defaultdict(set)
1 change: 0 additions & 1 deletion worlds/astalon/constants.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from typing import Final

GAME_NAME: Final[str] = "Astalon"
BASE_ID: Final[int] = 333000
43 changes: 16 additions & 27 deletions worlds/astalon/items.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,12 @@
from enum import StrEnum
from functools import cached_property
from itertools import groupby
from typing import TYPE_CHECKING, TypeAlias
from typing import TypeAlias

from BaseClasses import Item, ItemClassification

from .constants import BASE_ID, GAME_NAME
from .options import StartingLocation

if TYPE_CHECKING:
from . import AstalonWorld
from .constants import GAME_NAME
from .options import AstalonOptions, StartingLocation


class ItemGroup(StrEnum):
Expand Down Expand Up @@ -529,7 +526,7 @@ class AstalonItem(Item):
@dataclass(frozen=True)
class ItemData:
name: ItemName
classification: ItemClassification | Callable[["AstalonWorld"], ItemClassification]
classification: ItemClassification | Callable[[AstalonOptions], ItemClassification]
quantity_in_item_pool: int
group: ItemGroup
description: str = ""
Expand Down Expand Up @@ -615,11 +612,9 @@ class ItemData:
ItemData(BlueDoor.CAVES, ItemClassification.progression, 1, ItemGroup.DOOR_BLUE),
ItemData(
BlueDoor.CATA_ORBS,
lambda world: (
ItemClassification.progression
if world.options.randomize_candles or world.options.randomize_orb_multipliers
else ItemClassification.useful
),
lambda options: ItemClassification.progression
if options.randomize_candles or options.randomize_orb_multipliers
else ItemClassification.useful,
1,
ItemGroup.DOOR_BLUE,
),
Expand All @@ -630,9 +625,7 @@ class ItemData:
ItemData(BlueDoor.CATA_PRISON_LEFT, ItemClassification.filler, 1, ItemGroup.DOOR_BLUE),
ItemData(
BlueDoor.CATA_PRISON_RIGHT,
lambda world: (
ItemClassification.progression if world.options.randomize_candles else ItemClassification.filler
),
lambda options: ItemClassification.progression if options.randomize_candles else ItemClassification.filler,
1,
ItemGroup.DOOR_BLUE,
),
Expand Down Expand Up @@ -691,21 +684,17 @@ class ItemData:
ItemData(Switch.GT_UPPER_PATH_ACCESS, ItemClassification.progression, 1, ItemGroup.SWITCH),
ItemData(
Switch.GT_CROSSES,
lambda world: (
ItemClassification.filler
if world.options.open_early_doors and world.options.starting_location == StartingLocation.option_gorgon_tomb
else ItemClassification.progression
),
lambda options: ItemClassification.filler
if options.open_early_doors and options.starting_location == StartingLocation.option_gorgon_tomb
else ItemClassification.progression,
1,
ItemGroup.SWITCH,
),
ItemData(
Switch.GT_GH_SHORTCUT,
lambda world: (
ItemClassification.filler
if world.options.open_early_doors and world.options.starting_location == StartingLocation.option_gorgon_tomb
else ItemClassification.progression
),
lambda options: ItemClassification.filler
if options.open_early_doors and options.starting_location == StartingLocation.option_gorgon_tomb
else ItemClassification.progression,
1,
ItemGroup.SWITCH,
),
Expand Down Expand Up @@ -904,8 +893,8 @@ class ItemData:
ItemData(Orbs.ORB_MULTI, ItemClassification.useful, 3, ItemGroup.ORBS),
)

item_table = {item.name.value: item for item in ALL_ITEMS}
item_name_to_id: dict[str, int] = {data.name.value: i for i, data in enumerate(ALL_ITEMS, start=BASE_ID)}
item_table: dict[str, ItemData] = {item.name.value: item for item in ALL_ITEMS}
item_name_to_id: dict[str, int] = {data.name.value: i for i, data in enumerate(ALL_ITEMS, start=1)}


def get_item_group(item_name: str) -> ItemGroup:
Expand Down
8 changes: 4 additions & 4 deletions worlds/astalon/locations.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from BaseClasses import Location

from .constants import BASE_ID, GAME_NAME
from .constants import GAME_NAME
from .regions import RegionName


Expand Down Expand Up @@ -517,7 +517,7 @@ class LocationName(StrEnum):


class AstalonLocation(Location):
game: str = GAME_NAME
game = GAME_NAME


@dataclass(frozen=True)
Expand Down Expand Up @@ -1116,8 +1116,8 @@ class LocationData:
LocationData(LocationName.CATA_ORB_MULTI, RegionName.CATA_MULTI, LocationGroup.ORBS, Area.CATA),
)

location_table = {location.name.value: location for location in ALL_LOCATIONS}
location_name_to_id: dict[str, int] = {data.name.value: i for i, data in enumerate(ALL_LOCATIONS, start=BASE_ID)}
location_table: dict[str, LocationData] = {location.name.value: location for location in ALL_LOCATIONS}
location_name_to_id: dict[str, int] = {data.name.value: i for i, data in enumerate(ALL_LOCATIONS, start=1)}


def get_location_group(location_name: str) -> LocationGroup:
Expand Down
10 changes: 0 additions & 10 deletions worlds/astalon/logic/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +0,0 @@
from .instances import RuleInstance
from .main_campaign import MAIN_ENTRANCE_RULES, MAIN_LOCATION_RULES
from .mixin import AstalonLogicMixin

__all__ = (
"MAIN_ENTRANCE_RULES",
"MAIN_LOCATION_RULES",
"AstalonLogicMixin",
"RuleInstance",
)
Loading
Loading