thewca / tnoodle-lib

scrambling code portion of TNoodle
GNU General Public License v3.0
39 stars 15 forks source link

Code organization and plans for a js fork #12

Open canibanoglu opened 5 years ago

canibanoglu commented 5 years ago

Hello,

I've been writing a cubing tool for myself and scrambles have proven to be the hairiest part of the implementation. I've been hoping to avoid what I'm suggesting but I can't see any other tool in JavaScript that generates acceptable scrambles across different puzzles.

I have looked into the generated tnoodle.js file but this is far from ideal and has (unnecessary) dependencies on global objects (like window or document).

I have been reading through the codebase a little in preparation of a JS port and I just wanted to ask here if there are any upcoming plans to rewrite tNoodle. It doesn't have to be JS but I feel like the codebase needs a bit of cleaning up (I would like to understand the decision behind tightly coupling the representation of puzzles (svg) to the scramble generator).

I feel like I will go ahead with a JS port and make it available on npm (don't know when I will finisih it) and I would greatly appreciate if you could give me some pointers on where I should start within tNoodle, like general pointers to keep in mind.

Thanks a lot!

campos20 commented 5 years ago

The code do need some clean up and use a bit more standard features. We have plans of doing that in the mid-term future. Porting to js is more a long-term plan.

TNoodle started as a personal software from @jfly, perhaps he can explain the svg chose.

This Java code can generate scrambles.


import net.gnehzr.tnoodle.scrambles.PuzzlePlugins;
import net.gnehzr.tnoodle.utils.LazyInstantiator;

private String generateScramble(String typeScramble){
    try{

        SortedMap<String, LazyInstantiator<net.gnehzr.tnoodle.scrambles.Puzzle>> scramblers = PuzzlePlugins.getScramblers();
        LazyInstantiator<net.gnehzr.tnoodle.scrambles.Puzzle> lazyScrambler = scramblers.get(typeScramble);

        net.gnehzr.tnoodle.scrambles.Puzzle s = lazyScrambler.cachedInstance();
        return s.generateScramble().trim();
    }
    catch (Exception e){
        // Error dealing
    }
    return "";
}```
gregorbg commented 5 years ago

Hey @canibanoglu, just putting this here to let you know that a Kotlin rework of the entire scrambles module is in the works. This will also include the ability to compile the code down to JS without the nasty document and window references that GWT produces.

In general, I try to migrate everything to Gradle right now, so a loooot of stuff about project structure will change in the near future. Please refrain from doing a manual JS portation! We greatly appreciate your dedication, but I strongly feel that having two separate codebases for two languages is the wrong way to go.

canibanoglu commented 5 years ago

@suushiemaniac Thank you so much! I agree with you completely in that there shouldn't be two codebases striving to do the same thing.

I'm really happy to read that there is a Kotlin port going on. Is it open to public and if so do you need any help?

gregorbg commented 5 years ago

We need to figure out the Grade migration first, and I expect that this will take another week or two.

Afterwards, the Kotlin migration work can seriously start and then your help is very welcome :)

canibanoglu commented 4 years ago

Are there any updates about this?

gregorbg commented 4 years ago

Hey there! We have pulled the core scrambling code out into its own repository. Your suggestions mostly pertains to porting that scrambling code.

There is currently absolutely no progress to report here, because our main focus currently lies on rewriting the server+frontend part.

I'm moving this issue over to tnoodle-lib