Conversation
Generate all possible case boards for all possible locations where the case rule can be applied, then compare the resulting permutations. If a matching permutation is not found, then the case rule was not applied correctly.
enerate all possible case boards for all possible locations where the case rule can be applied, then compare the resulting permutations. If a matching permutation is not found, then the case rule was not applied correctly.
The default check for case rules is to compare the cases built to the cases returned by getCases function. Some of the code removed doesn't work properly, but comparing directly to the generated cases should work.
When a node has children, it doesn't make sense to generate cases from it. Will not prompt user with case locations.
The default checkRuleRaw for case rules will be correct if the getCases function is implemented correctly. It is tricky to check that the cases created logically follow from a given case rule without creating all cases. That being said, trying to test whether or not the getCases function works as intended is a bit tricky. This needs to be monitored in the future.
|
There is an issue related to when a user wants to create their own cases. Some case rules in LEGUP are "smart" in that they won't generate cases where the next step leads to a contradiction. Consider the Nurikabe There are three solutions Bram brought up:
It is probably best to implement option 2, but I need to figure out how to match the possible cases in a reasonable amount of time. |
Description
As #777 lays out, case rules should be tested. However, it is tricky to make sure that they will work in all cases. Case rules may generate anywhere between 1 and 10 cases, depending on what the rules describe, and not all case rules have a logical way of verifying that the rule was applied correctly.
Consider the finish room case rule in Nurikabe. What metrics could be used to verify that the cases are correct? The number of branches (what if we have duplicate branches)? The number of modified cells (what about different-sized rooms)? The rooms created being complete (what if we have duplicate branches (again))? There might not be a logically sound way to verify that this rule was applied correctly.
Instead of coming up with the correct logic for every case rule for every puzzle, we can generalize a way to guarantee that a case rule is applied correctly simply by matching the created branches to the boards generated by the case rule. This involves checking every possible matching of boards to the cases generated; when n <= 10, this is manageable. If the limit of the number of branches allowed for a given node increases, then this may become a problem and will need to be optimized.
A big assumption this makes is that the getCases function returns the right cases when applying the case rule. There really is no good way of programmatically testing that the getCases function is correct, but generally it is easier to convince oneself that the generated cases are as expected. The getCases function will need to be monitored in the future to make sure that this assumption holds.
Closes #777, #638, #643
Type of change
How Has This Been Tested?
On smaller puzzles, I have messed around with standard proof creation and applying case rules and direct rules in various situations. All case rules seem to check out when manually creating cases, as well as shifting the order of cases or changing the type of rule to a direct rule.
In larger puzzles, generating all cases in certain situations seems to massively slow down the program. I believe that the issue is due to the specific getCases function not terminating early.
Checklist: