Code Monkey home page Code Monkey logo

tnoodle-lib's Introduction

TNoodle Logo

TNoodle-LIB

TNoodle is a software suite that contains the official WCA scramble program. It consists of the core scrambling code (primarily written in Java) as well as a UI and server to generate a fully autonomous JAR file

You are looking at the core scrambling code portion. This repository hosts an independent build for the essential mechanics that generate Java Strings representing twisty puzzle scrambles.

If you are interested in the webserver part, look here

Build Status

WCA Scramble Program

The official scramble program for the World Cube Association has been part of the TNoodle project since January 1, 2013. It will contain the sole official scramble program for the foreseeable future.

All WCA official competitions must always use the current version of the official scramble program. This is available from https://www.worldcubeassociation.org/regulations/scrambles/

Note that only the scramble program part of TNoodle is "official". Other TNoodle projects may be convenient for certain uses (including at official competitions), but do not have any official status.

"Scramble Program" vs. "Scrambler"

Officially, TNoodle-lib is a scramble program, while a scrambler is a human. It is fine to refer to TNoodle as a "scrambler" colloquially, but please try to use the official convention wherever possible.

Project Details

TNoodle is organised as a multi-project Gradle build. The build files are written in the type-safe Kotlin dialect.

Every sub-project has its individual artifact configuration and build.gradle file. Furthermore, there is a central buildSrc folder, which is automatically sourced by Gradle. It contains common code and shared configuration setups.

Overview

Gradle is served through the use of a Gradle wrapper available as gradlew (UNIX systems) or gradlew.bat (DOS systems) It is recommended to set up an alias to simplify task generation, along the lines of alias gw='./gradlew --parallel'.

Get an overview of the core project tasks by executing

./gradlew tasks

Setup

Gradle automagically handles all dependencies for you. You just need an Internet connection upon your first build run!

WCA Scramble Program

When you're ready to develop, just go ahead and code! There is no UI to this part of TNoodle. You can always execute the full integration and unit test suite via:

./gradlew :scrambles:check

To build a distributable .jar file, run:

./gradlew :scrambles:assemble

You cannot run the resulting .jar, because it is conceived as a Maven artifact. We recommend using the online distribution hosted at Maven Central

If you really want to use a local build in your project, execute:

./gradlew :scrambles:publishToMavenLocal

and point whatever Maven-style build tool you're using to your local .m2 repository.

Important note: You must never use a custom build for any official competitions. Contact the WCA Board and the WRC if you have any questions about this.

Notes

  • Each project is a fully fledged Gradle project (they each have a build.gradle.kts file). Your IDE should be able to import Gradle build structures nowadays. if not, this is a good indicator that your IDE is outdated and should be replaced.

tnoodle-lib's People

Contributors

campos20 avatar clementgallet avatar cs0x7f avatar gregorbg avatar jfly avatar lgarron avatar mcccs avatar mollerz avatar pedrosino avatar pluscubed avatar timreyn 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

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

tnoodle-lib's Issues

Log4j CVE-2021-44228 Vulnerability

Actual (problem) behavior

tnoodle-lib depends on a version of log4j that includes a severe security vulnerability as described here: https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-44228

Expected behavior

tnoodle-lib should depend on log4j version 2.16.0 or later. This should be as simple as updating a build dependency and running some tests to make sure nothing breaks.

Steps To Reproduce

  1. Build tnoodle-lib or a dependent project like my tnoodle-cli and see that it downloads log4j version 2.13.3

Desktop (please complete the following information):

  • OS: MacOS and Windows
  • Browser including version n/a
  • TNoodle Version: latest (0.18.0)
  • Java version: I'm using Java 11 which is generally considered safe from this CVE, but since tnoodle-lib also runs on Java 8, it should be upgraded to prevent any issues from users of that Java version.

Screenshots [OPTIONAL])

My gradle build cache after building tnoodle-lib from source showing the dependency on a vulnerable version of log4j
Screen Shot 2022-01-24 at 10 45 12 PM

Additional context [OPTIONAL]

I'll just share the link to the official CVE description again for ease of access.
https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-44228

Provide short code samples for generating scrambles and SVG strings

A year or so ago, I was trying to build an Android cube timer app. However, I found it quite difficult to find out how to use the tnoodle library for generating scrambles and scramble images. Ultimately, I figured out the usage from looking at the code of other projects using tnoodle-lib on GitHub and the tnoodle-samples repository, but this was quite tedious and time consuming, even though using tnoodle-lib for generating scrambles is actually very easy and only takes a few lines of code.

To make it easier and more accessible for people to use tnoodle-lib in their own projects, would it be possible to add some simple code snippets that show how to generate scrambles and scramble SVG strings for various kinds of puzzles in the README file of this repository or the tnoodle-samples repository?
For example, for generating a scramble for a 3x3x3 cube, the code sample could be something simple like

Puzzle puzzle = new ThreeByThreeCubePuzzle();
String scramble = puzzle.generateScramble();

and for generating a scramble SVG string, the code sample could be something like

Puzzle puzzle = new ThreeByThreeCubePuzzle();
String scramble = puzzle.generateScramble();
String SVGString = puzzle.drawScramble(scramble, null).toString();

Flitering for duplicates

There was a post in CF today asking about repeated 2x2 scrambles, and someone found a duplicate 2x2 scramble within the same comp. This should probably be filtered out.

Scrambles ending in the same state but in a different orientation should be considered duplicates. However, whether a scramble that is the same as another scramble applied to a different starting orientation is a dupliate needs to be discussed.

Kotlin (KMP) support

As a developer, I'd like to use tnoodle-lib for web/desktop/iOS platforms.
I think it's possible to rewrite the code so it can be used in Kotlin multiplatform projects. Any thoughts on this?

Code organization and plans for a js fork

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!

[Question] How are scrambles generated?

Hey there, sorry for opening an issue for this, I tried to find any other resources of how are the official scrambles generated for competitions.

I'm currently working on a timer app, written in Python. The way I implemented the scramble generation is not the best nor the official way. I would like to implement official scrambles into my app and possibly make a Python module out of it. If you all are ok with it.

I don't need actual code, just an explanation of how it is done.

Thanks

Couldn't get SecureRandomInstance

Hi! On android library when I make a scramble I see this exception:

E/Puzzle: Couldn't get SecureRandomInstance java.security.NoSuchProviderException: SUN at java.security.SecureRandom.getInstance(SecureRandom.java:186) at net.gnehzr.tnoodle.scrambles.Puzzle.getSecureRandom(Puzzle.java:124) at net.gnehzr.tnoodle.scrambles.Puzzle.<init>(Puzzle.java:120) at puzzle.MegaminxPuzzle.<init>(MegaminxPuzzle.java:65) at java.lang.reflect.Constructor.newInstance(Native Method) at net.gnehzr.tnoodle.utils.LazyInstantiator.newInstance(LazyInstantiator.java:85) at net.gnehzr.tnoodle.utils.LazyInstantiator.cachedInstance(LazyInstantiator.java:104)

I see this when I call the cached instance of a LazyIntantiator:

LazyInstantiator<Puzzle> lazyPuzzle = Constants.getInstance().WCA_PUZZLES.get(shortName); try { puzzle = lazyPuzzle.cachedInstance(); } catch (LazyInstantiatorException e) { Log.wtf("ScrambleConfig", e); }

Could you help me please? I'm not sure why is this happening.

This seems not to affect the scramble but I'm a little worried of the impact in production.

Thank you!

Puzzle.generateSeededScramble() should use a well defined PRNG

Right now, we use SecureRandom, which is implemented differently on different platforms. For WCA scrambles, that's fine, because we assume that each of these different implementations is cryptographically secure. However, for seeded scrambles (good for 2 people racing), we want the scrambles we generate to always been the same, regardless of platform. Perhaps we should add in a MersenneTwister (Yarrow? Fortuna?) implementation, specifically for seeded scrambles?

Proposal: in big cube scrambles, sort same-axis moves to decrease regrips.

In big cube scrambles, a sequence with unnecessarily many regrips might appear, such as "Rw Lw' R2 L", where all the moves are across the same axis, and therefore the order of them doesn't change the scramble state.

My proposal is that anytime moves on the same axis appear in sequence, they are sorted, such that you perform all moves starting with the same letter first, e.g. "L' Lw 3Lw2 3Rw Rw' R2" instead of switching back and forth between L and R.
i propose sorting moves left to right, top to bottom, and front to back, but i'm impartial to the directions.

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.