PuzzleScript icon indicating copy to clipboard operation
PuzzleScript copied to clipboard

think about Clementsparrow: Optimization: Expand rules with multi-layer properties layer by layer

Open increpare opened this issue 4 years ago • 2 comments
trafficstars

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

increpare avatar Aug 16 '21 14:08 increpare

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

increpare avatar Mar 10 '22 04:03 increpare

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....

Bildschirmfoto 2022-03-10 um 06 51 44

increpare avatar Mar 10 '22 05:03 increpare