What started out as an not really serious question, actually turned into a pretty interesting problem. It's also got more in common with the design game than I first expected, having had a try at it myself now.
Yeah, I just realized as well that set partitioning doesn't work here. If you encode the numbers in unary, the problem is not NP-complete, because you can just use dynamic programming to solve it in polynomial time; and if you encode it in binary, then the amount of terrain pieces you use for the partition primitive is exponential in the length of the numbers in binary.
I still liked that the idea you used to design that primitive, I think it could also be used as the unit primitive, if you sacrifice half of the lemmings of each unit by default (overall 25% to save then); it doesn't require to compress the lemmings.
However I think I found a way to reduce an instance of
SAT (more precisely for expressions in conjunctive normal form) to Lemmings in polynomial time, and incidentally I need the unit primitive for it as well. However I can't use blockers in the setup, so I need a different setup for it. Also, it can easily be adapted to use only one exit, and I got an idea to use only one entrance as well (I didn't think about that actually when I first wrote up the challenge).
Here's a sketchy description of the scheme, an example level for L++ is attached:
For each literal you got one entrance, from which the lemmings drop into a 'unit' (by ccexplore's earlier description), essentially forcing the entire group to go path A or path B. Path A (the lower one) corresponds to the literal being assigned the value
true, path B the value
false.
In the example level, the 'unit' isn't quite working yet, as you can use diggers to desynch the lemmings in a 'unit' thus splitting up the group. However, in DOS physics that 'unit' would have to be adapted anyway, and I'm pretty sure something could be come up with (preferably something without compression required, I might try to think something up for it).
Then for each literal and each negated literal, there's a path consisting of M slopes where M is the number of clauses in the conjunctive normal form. If that literal appears in the Nth clause, there's opportunity to dig after the Nth slope to turn a lemming around onto a path to a 'box' corresponding to the clause. If it doesn't appear, then there's no such oportunity.
So, once you choose whether to pick the literal or its negation, you can send a lemming to every 'box' that contains that literal (or its negation respectively). If you manage to get at least one lemming into each 'box', then all clauses can be fulfilled. So it must be ensured that for each 'box', exactly one lemming can be saved (this is achieved using a 1px wide wall to dig to get around the splat distance for that digger).
The requirement of lemmings to save is the amount of clauses, which is achievable iff you get a lemming into each of the 'boxes' for each clause, i.e. fulfilling every clause and subsequently the entire expression. For each entrance, an amount of M+1 lemmings is sufficient (you could also use the 1 plus the maximum over the number of clauses the literal appears in, and the number of clauses its negation appears in). Plus 1, because in my current setup a bomber is used for each entrance. The amount of diggers the same as for lemmings, plus M (for digging the 1px walls).
The example level shows the Lemmings instance for the SAT expression (a
v b
v -b)(-b
v -a)(-a
v b), where
v denotes the logical OR, - denotes NOT, and between the clauses there's an implicit AND. The expression can be satisfied using either -a and b or -a and -b. So in the example level, in the lower pair of lanes (literal a) you pick the upper of the two, and for the upper pair is doesn't matter. You dig whenever you get the opportunity (above the flipped T shaped steel structure), and you'll get at least one lemming into every box.
sentr.txt is an idea how to split up a group from a single entrances into groups of sizes of ones choice. Of course, the structure on the left should be steel entirely, and the skillset for the rest of the level shouldn't allow backroutes to it. A problem with this approach is that the lemmings won't come up spaced perfectly evenly, but if the 'unit' primitive doesn't require compression, then this shouldn't be of an issue.
Quote
Hahaha, this is awesome. Happy birthday, prove Lemmings can be made NP-complete given certain criteria
Thanks a lot, everyone.
I hope you had an entertaining read, mostly courtesy of ccexplore.
Mod Edit: Restored attachments.