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

Takes too long for some puzzles #1

Open
denilsonsa opened this issue Jun 14, 2015 · 2 comments
Open

Takes too long for some puzzles #1

denilsonsa opened this issue Jun 14, 2015 · 2 comments

Comments

@denilsonsa
Copy link
Owner

Since this solver uses a plain brute-force algorithm, some puzzles may take too long to solve.

Is there any kind of way to cut some branches of the brute-force, so that it won't take as long to solve? I don't have a clear answer right now, but I'm documenting here some of these slow puzzles.

ssSs
sD3s
S23s
d33t
dDt2
TttT
DSs2ss
2D2dtS
d222t2
dd2tTT
dTdsSt
d2t32t
dD323T
Ddd2sS
tTDDSs
t2t33s
2d33ts
S22Ts
tTtt
t42t
d3tT
d32D
Dd3d
ddd
ttt22d2S
tt23S2s2
tT232ssd
tTttDsD
denilsonsa added a commit that referenced this issue Jun 28, 2015
* Split the main JavaScript file into 3 files.
* Modifying the UI code to solve the puzzle asynchronously.
* Adding some feedback to the user, showing that the computation is
  being done in the background.
* Allow the user to abort the computation.

This change will make it possible to add the "auto-solve" option from
pull request #2, and also avoids freezing the browser (issue #1).
@denilsonsa
Copy link
Owner Author

Possible improvements:

  • Blocked path checking
    • Upon placing a diagonal edge, detect if blocking the crossing diagonal would lead make the puzzle unsolvable. An example is the 4 block, which requires 8 edges around it. If any of those edges are blocked, the solution will not be found. This can be implemented by having a new attribute available_edges on each Node. If available_edges < missing_edges, then stop exploring the current solution branch.
  • Trying edges in a different order
    • Some nodes have very few connection possibilities, sometimes a single one (e.g. a 4 node). These could be tried first.
    • Will require a lot of changes to the code, and will require some post-processing to calculate the edge directions and colors.
    • Care must be taken to not end up with isolated (circular?) paths that are uncolored.

@jbosboom
Copy link

My solver maintains a set of possible colors for each edge and implements some simple inference rules that prune these sets. My blog post about LYNE briefly outlines an inference rule reasoning about paths, not just individual nodes or edges, though I didn't find it necessary to implement. (I link rather than describing the rules here so you can figure them out on your own if you'd prefer. I enjoyed writing my solver more than playing the game itself, and I don't want to spoil that for you.)

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

No branches or pull requests

2 participants