PuzzleScript
PuzzleScript copied to clipboard
think about Clementsparrow: Optimization: Expand rules with multi-layer properties layer by layer
Currently, when a property is found on the LHS of a rule and it's not a single-layer property (i.e. it includes objects that are on different layers), the rule is expanded for each value of the property. Instead, it could be expanded for each layers it has objects in, and benefit from the optimizations available to single-layer properties. Also reducing the number of rules that have to be tested.
The problem is that the resulting single-layer property might not exist as an identifier, which means that we have either to create an identifier for it, or use a different representation than identifiers (masks?) at this stage of the parsing. Also, we would need to compute the mappings implying these new single-layer properties, which in turn can create new, multi-layer, properties.
Another option would be to do as we currently do, but merge the rules that can be described with single-layer properties afterward. This option seems more difficult to code and less efficient, but it could actually make the code more robust and general (merging user-provided rules, for instance), by moving out of ruleToMask the need to consider single-layer properties.
The same optimization could be performed for property rule parameters.
https://github.com/ClementSparrow/Pattern-Script/issues/20
I didn't think this would be a thing that came up much, but the test suite lists almost 5k example rules that could be optimised in some way maybe
While it looks like it provides benefits in some of the most complicated games (reduced the rule count by about 30% in Cyber Lasso game at the same time as breaking it), it also...at least my attempt at it, broke the tests for some of the more formidable games in ways that are not so obvious...I suspect there are semantic subtleties at play here that might stuff things up. Best put off for another day with more brainpower....