Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solver find solutions method #79

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open

Solver find solutions method #79

wants to merge 19 commits into from

Conversation

IronicJuice
Copy link
Collaborator

Added Solver.FindSolutions(), which returns all, or a certain number of solutions to a given board. Can also randomize.

Also added Board.Validate with tests

There are several known improvements that can be made, but these will be part of a larger performance test of the solver.

Copy link
Owner

@frederikja163 frederikja163 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall this is looking good. A few minor changes requested.

Also (and not sure if this is applicable) didnt we already implement a solver method? Is there any reason you cant extend the capabilities of the current method instead of adding a new method?

// If a limit is specified and the result count exceeds it, return only the correct number of solutions.
if (limit != 0 && result.Count > limit)
{
return result.Take(limit).ToList();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason to take a limit here? Shouldn't SolveRecAll already give you the limit?

Copy link
Collaborator Author

@IronicJuice IronicJuice Oct 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is to avoid edge cases where the list contains one too many solutions. I'm not sure if these cases exist, but I'm not sure how to properly test for it

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then i think you should try to gain an understanding of that. A test like this is really error prone and probably not even needed.

@frederikja163
Copy link
Owner

Would be nice if you could mention the known improvements here for further documentation. Also when opening pull requests without an issue attached listing the reasons for the changes could help when reviewing.

@IronicJuice
Copy link
Collaborator Author

The purpose of the FindSolutions method, is to allow other wanted features late. IsProper() can be infered by asking if FingSolutions() returns more than one solution. These found solutions can also be used to create boards.

I am working on a separate branch to test improvements such as:

  • Smarter candidate selection using heuristics
  • Parallel solving (multithreading)
  • More aggressive candidate pruning
    and any other I might stumble across as long as I can justify them with increased performance or other metrics.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants