Could there be something like "matched as" for rulebooks in general?

The ability to set action variables via matched as... (as described in WWI 12.10 Action variables) is very handy, but there doesn’t seem to be anything like it for rulebooks in general.

Looking at the way that such variables are defined (i.e. attached to the action name) makes it seem like there must be special case code in the compiler to detect when an action name is specified and interpret the “matching prepositions” relative to their definitions for that action name.

How feasible would it be to create general case code for this that doesn’t depend on an action name being present in the rule preamble? As an example of what I’m thinking of, it would enable the following pseudo-code:

Radio range is a rulebook. The radio range rules have outcomes in-range (success) and out-of-range (failure).
The radio range rulebook has a thing called source (matched as "from").
The radio range rulebook has a thing called destination (matched as "to").

Radio range from a low-gain radio to a high-gain radio (this is the high-gain can receive weak signals rule):
	in-range.

Radio range from a high-gain radio to a radio (this is the high-gain can broadcast strong signals rule):
	in-range.

Radio range from a low-gain radio to a high-gain radio (this is the low-gain radios have limited broadcast range rule):
	if the number of moves from the location of the source to the location of the target is at most 3:
		in-range;
	otherwise:
		out-of-range.

I believe these variables are matched as part of the action pattern, which is also what handles things like “jumping in the Stairwell” and “singing in the presence of another person”. There’s not really anything equivalent to action patterns for other kinds of values.

I thought I read somewhere that object-based rulebook patterns are actually a special kind of action pattern that just doesn’t have an action, so maybe it would be possible to handle something like this using that…? I wouldn’t expect that to work for value-based rulebooks though…

Action patterns are just syntactic sugar for conditions. “Check going from the Kitchen through the hot door” is equivalent to “Check going when the room gone from is the Kitchen and the door gone through is the hot door.”

Rules can have conditions on their rulebook variables in exactly the same way. For your example, you could write

Radio range when the source is a low-gain radio and the destination is a high-gain radio (this is the high-gain can receive weak signals rule):

Using “matched as” for a similar shortcut is reasonable. I don’t see any conceptual problem.

2 Likes