Giter Site home page Giter Site logo

denilsonsa / lyne-solver Goto Github PK

View Code? Open in Web Editor NEW
23.0 4.0 3.0 28 KB

Solver for LYNE game.

Home Page: http://denilsonsa.github.io/lyne-solver/lyne-solver.html

License: MIT License

CSS 9.78% HTML 23.87% JavaScript 66.35%
lyne solver puzzle-solver puzzle

lyne-solver's Introduction

LYNE puzzle solver

Donation - buy me a coffee

This is a solver for LYNE game. It can also gradually show the connections, which is a helpful way to get a hint without showing the entire solution.

The solver is written in JavaScript and HTML+CSS+SVG. It should work on any modern browser, desktop or mobile. It has been tested on Google Chrome 43 and Mozilla Firefox 38.

Open the solver online, in your browser!

How to use this solver

Write the puzzle description as text in the main text box. Click Solve it! to find a solution. Drag the slider to gradually reveal random lines until the full solution is shown.

The puzzle description is plain text formed by the following characters:

  • Lower-case t, s, d, p, h letters denote shapes.
  • Upper-case T, S, D, P, H letters denote terminator nodes (shapes that are white inside). Paths will always start and end in a terminator node.
  • Numbers 1, 2, 3, 4 denote gray shapes that have 1, 2, 3 or 4 paths passing through them.
  • Space character denotes an empty space.
  • Alternatively, the 0 (zero) character also denotes an empty space.

Note that the original LYNE game only contains 3 shapes and does not have all 4 types of gray nodes.

Offline usage

This solver can be downloaded and used offline. However, running it from the local filesystem on Google Chrome will not work due to "same origin" security restrictions. Read more about it, or follow issue 47416. Firefox seems to be able to run it from the local filesystem without any issue.

About LYNE

LYNE is a puzzle game written by Thomas Bowker using Unity. It is available on digital distribution platforms: Google Play, Amazon App Store, iTunes, Steam, Humble Bundle Store, itch.io. It is also available DRM-free.

About this solver (under-the-hood information)

This solver was written by Denilson Sá using modern web technologies. The list below contains some highlights of the underlying code:

  • The gray diamond shape in the background was written using pure CSS, with a combination of linear-gradient() and background-size, inspired by CSS3 Patterns Gallery.
  • The layout is done using flex and viewport-relative units, which means it is responsive and should adapt to any screen size. Some scrolling might be required if the display is not wide enough, and this was a deliberate choice.
  • The slider is HTML5 <input type="range">.
  • Pure JavaScript code without using any additional library.
  • Event-handling through oninput event, which fires as soon as the text or the slider changes their value. This gives a faster feedback than onchange and is much better than using onkeydown/onkeyup/onkeypress events, because it will work even if the value is changed by the mouse, and it won't run the even handler if the user just presses keys without changing the content (e.g. arrow keys).
  • Graphics built using SVG. Each shape is defined once using <defs> and <symbol>, and later used as many times as needed with <use>.
  • Dynamically-generated SVG content. For some reason, browsers do not allow modifying viewBox attribute in <svg> element, nor modifying any of the relevant attributes of <use> element. For this reason, the entire SVG source-code is rewritten into a string and then added to the document (using innerHTML).
  • The solver is implemented as a simple recursive backtracking algorithm.
  • The algorithm runs in a background thread using Web Workers.
  • Many LYNE puzzles have multiple solutions. The solver finds one arbitrary solution. It is possible to adapt the code to find all solutions, but it would also require additional code to remove duplicate solutions.
  • There is function to output a plain text representation of the solution, but there is no UI for it. It was implemented as a way to check if the algorithm worked, before the SVG-building function was written.

lyne-solver's People

Contributors

denilsonsa avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

lyne-solver's Issues

Takes too long for some puzzles

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.