increpare / PuzzleScript

Open Source HTML5 Puzzle Game Engine
MIT License
903 stars 159 forks source link

optimisation for flags #701

Closed increpare closed 3 years ago

increpare commented 3 years ago

"[ dash ] [ dragon ] -> [ dash ] [ down dragon ]" doesn't need to compute exactly where dash is, mask suffices. and doesn't need to do replacements for it.

increpare commented 3 years ago

q: how often is the mask recalculated from scratch oh, only at the start of turns. not an easy optimisation then.

or, I guess if a cell-row doesn't actually replace anything (which I can detect after my fix to #741 ), you can early out as soon as you find the first match. SOOO maybe it's doable.

increpare commented 3 years ago

otoh you don't know for sure the patterns aren't overlapping/interfering with eachother? that makes this a much more annoying task.

ClementSparrow commented 3 years ago

I think Puzzlescript currently doesn't care if the cellrows overlap? (maybe it should?)

For instance, with one player object and one crate object, the following code:

[ Player ] [ > Player | Crate ] → [ Wall ] [ > Player | > Crate]

never produces a wall when a crate is pushed because it is immediately replaced with a moving player. So it does the same thing as the usual rule [ > Player | Crate ] -> [ > Player | > Crate ] except that it considers the application of the rule changed the level content (even if it actually don't), and thus enters an infinite loop.

increpare commented 3 years ago

[.For an individual rule application yeah the parallel rows can overwrite each other awkwardly, but in the context of a rule-group/repeated applications of a single rule it verifies the contents before each new application (IIRC). ]

increpare commented 3 years ago

thought about this, don't think it's worth it - it's specializing for a very particular type of use that I think increases complexity more than it saves time