scrambling code portion of TNoodle

Related tags

SDK tnoodle-lib
Overview

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 Bintray

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.
Comments
  • Implement optimal SQ-1 solver based on recent `sq12phase` changes

    Implement optimal SQ-1 solver based on recent `sq12phase` changes

    Square-1 is now using the optimal solver as backend, thanks to the lightning-fast fixes from @cs0x7f :)

    Requesting review from experienced people because this roots deep into the solver

    opened by gregorbg 8
  • Log4j CVE-2021-44228 Vulnerability

    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

    opened by thehale 6
  • Add a flag to determine whether the solution should be inverted.

    Add a flag to determine whether the solution should be inverted.

    The behavior of Search(FullCube fc) is different from previous one. By default, Search(FullCube fc) won't inverse the solution to generator. To generate scrambles, use Search(FullCube fc, int verbose) with verbose = Search.INVERSE_SOLUTION instead.

    opened by cs0x7f 3
  • Broken link to https://bintray.com/thewca in README.md?

    Broken link to https://bintray.com/thewca in README.md?

    This part of the README: https://github.com/thewca/tnoodle-lib/blame/master/README.md#L58 links to https://bintray.com/thewca, which gives a 410 Gone. Is there a working link?

    opened by jfly 1
  • Provide short code samples for generating scrambles and SVG strings

    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();
    
    opened by NikhilSDate 1
  • [Question] How are scrambles generated?

    [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

    opened by MrFellox 1
  • Get rid of System.out.println & printStackTrace calls

    Get rid of System.out.println & printStackTrace calls

    These are annoying, and can't be controlled in the same way that logging can. Plus, thewca/tnoodle#112 kind of requires this.

    This issue can be closed once we've gone through all our code and removed the offending calls, and then added a precommit hook to make sure we don't add any new ones.

    opened by jfly 1
  • Add optimal solver in WCA metric

    Add optimal solver in WCA metric

    Since (x, y) is counted as a single move in WCA metric, the number of states that can be solved in 11 moves is much larger than that in face turn metric. Similarly, the search space is also much larger than that in face turn metric at specific move limit.

    On my laptop, the average solving time spent for checking 11-move solvability is about 10ms for a random state. However, for specific states (e.g. 15-move scrambled state), it might take several seconds to do the verification.

    opened by cs0x7f 1
  • Migrate to Java 8 language level

    Migrate to Java 8 language level

    Recent Gradle versions have deprecated Java 6. We kept J6 compatibility for Android, but even there J8 is fine these days. So I migrated everything and even cleaned some static code analysis warnings while I'm at it.

    opened by gregorbg 0
  • Fix threephase initStatus after reading file from disk

    Fix threephase initStatus after reading file from disk

    See title. This is essentially replicating the condition from https://github.com/suushiemaniac/tnoodle-lib/blob/64eae76555321ac6801f817c4e9deb3cf8815c9a/threephase/src/main/java/cs/threephase/Edge3.java#L166

    opened by gregorbg 0
  • Add back reflection-based Puzzle registry

    Add back reflection-based Puzzle registry

    Now that the individual scramblers have been extracted, we can basically reproduce PuzzlePlugins.

    Merging as soon as Travis says Yes, because this reinstates a previously existing feature.

    opened by gregorbg 0
  • Proof of concept: Integrate 555 random state scrambles

    Proof of concept: Integrate 555 random state scrambles

    Using the scrambler from https://github.com/cs0x7f/cube555 with some minor adjustments (mostly for inverting solutions). The code has not been officially reviewed or sanctioned by WST or WRC at this point!

    Contains some duplication from the error handling of ThreeByThreeCubePuzzle. At this point in time, I just wanted to come up with "something that works":tm:. No need to formally review, but feedback is always welcome :smile:

    opened by gregorbg 0
  • Add POC for

    Add POC for "layered randomization" big cube scrambles

    Based on a discussion about allowing 5x5 misscrambles, which pointed us back to https://github.com/thewca/tnoodle-lib/issues/17

    Currently, this scrambles all layers that have centers using 3x3 random state scrambles from outside to inside, except for the innermost layer of even NxN, which resorts to using a 2x2 random state scramble. The model scales to any NxN automatically, meaning we can apply the concept to 6x6 and 7x7 on a whim.

    As of the intial PR, the outermost layer (the "reduction stage") is not scrambled with a 3x3 random state, although this can be fixed by literally changing one character in the source code (changing a one to a zero in the constant EXCLUDE_OUTER_LAYERS definition)

    Obviously this is not tested thoroughly because it's intended as a proof of concept at this stage. These scrambles are not WCA-legal! We also have not had a second pair of eyes to check the original mathematical analysis that prompted this approach.

    Feel free to discuss!

    opened by gregorbg 1
  • Proposal: in big cube scrambles, sort same-axis moves to decrease regrips.

    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.

    opened by carlemilex 1
  • Kotlin (KMP) support

    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?

    opened by hukpo 1
  • Flitering for duplicates

    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.

    opened by xsrvmy 3
  • Code organization and plans for a js fork

    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!

    opened by canibanoglu 6
Owner
The World Cube Association
Official projects for the World Cube Association (WCA)
The World Cube Association
A simple progress loader inspired by Can you Code this UI? Volume 6! - https://stories.uplabs.com/can-you-code-this-ui-volume-6-7bd09fa6dd92#.nyh2zhpvb

SlidingSquaresLoader Sliding Square Loader - A simple progress loader inspired by Can you Code this UI? Volume 6! Gradle Step 1. Add the JitPack repos

Hamza Fetuga 151 Jul 26, 2022
The library that removes all boilerplate code allowing you to display lists with few lines of code.

VsRecyclerView The library that removes all boilerplate code allowing you to display lists with few lines of code. Gradle androidExtensions { expe

Valeriy Shtaits 13 Jun 19, 2021
Qart is Android App that's based on CuteR project. App generate QR code that merge a picture. So the QR code looks more beautiful.

Qart is Android App that's based on CuteR project. App generate QR code that merge a picture. So the QR code looks more beautiful.

scola 1k Dec 16, 2022
This is a sample Android Studio project that shows the necessary code to create a note list widget, And it's an implementation of a lesson on the Pluralsight platform, but with some code improvements

NoteKeeper-Custom-Widgets This is a sample Android Studio project that shows the necessary code to create a note list widget, And it's an implementati

Ibrahim Mushtaha 3 Oct 29, 2022
Advent of Code 2021 in Kotlin, solved by myself. Focus on code readability. With GitHub Actions all puzzles are executed and their solutions printed

Advent of Code 2021 in Kotlin Focus on Code Readability. With CI Solution Printing. Welcome to the Advent of Code1 Kotlin project created by michaeltr

Michael Troger 1 Dec 12, 2021
Appleader707 1 Aug 9, 2022
Charting library for Android applications. Automatically exported from code.google.com/p/achartengine

achartengine Charting library for Android applications. Automatically exported from code.google.com/p/achartengine AChartEngine is a charting library

Dan Dromereschi 742 Jan 7, 2023
A blazing fast, powerful, and very simple ORM android database library that writes database code for you.

README DBFlow is fast, efficient, and feature-rich Kotlin database library built on SQLite for Android. DBFlow utilizes annotation processing to gener

Andrew Grosner 4.9k Dec 30, 2022
Event bus for Android and Java that simplifies communication between Activities, Fragments, Threads, Services, etc. Less code, better quality.

EventBus EventBus is a publish/subscribe event bus for Android and Java. EventBus... simplifies the communication between components decouples event s

Markus Junginger 24.2k Jan 7, 2023
Grab’n Run, a simple and effective Java Library for Android projects to secure dynamic code loading.

Grab’n Run, a simple and effective Java Library for Android projects to secure dynamic code loading.

Luca Falsina 418 Dec 29, 2022
A blazing fast, powerful, and very simple ORM android database library that writes database code for you.

README DBFlow is fast, efficient, and feature-rich Kotlin database library built on SQLite for Android. DBFlow utilizes annotation processing to gener

Andrew Grosner 4.9k Dec 30, 2022
A simple NoSQL client for Android. Meant as a document store using key/value pairs and some rudimentary querying. Useful for avoiding the hassle of SQL code.

SimpleNoSQL A simple NoSQL client for Android. If you ever wanted to just save some data but didn't really want to worry about where it was going to b

Colin Miller 389 Sep 25, 2022
A simple NoSQL client for Android. Meant as a document store using key/value pairs and some rudimentary querying. Useful for avoiding the hassle of SQL code.

SimpleNoSQL A simple NoSQL client for Android. If you ever wanted to just save some data but didn't really want to worry about where it was going to b

Colin Miller 389 Sep 25, 2022
Android StackBlur is a library that can perform a blurry effect on a Bitmap based on a gradient or radius, and return the result. The library is based on the code of Mario Klingemann.

Android StackBlur Android StackBlur is a library that can perform a blurry effect on a Bitmap based on a gradient or radius, and return the result. Th

Enrique López Mañas 3.6k Dec 29, 2022
From UI Proposal to Code :notes::arrow_forward:

Music Player: From UI Proposal to Code This is a prototype made for the article. This is not a real music player and don't expect it is. Some develope

André Mion 3.5k Dec 30, 2022
From UI Proposal to Code :notes::arrow_forward:

Music Player: From UI Proposal to Code This is a prototype made for the article. This is not a real music player and don't expect it is. Some develope

André Mion 3.5k Jan 9, 2023
DuGuang 1k Dec 14, 2022
Chandrasekar Kuppusamy 799 Nov 14, 2022
Animated Loader or Animated Progress Dialog android code.

AnimatedLoadingIndicator LoadingIndicator This is a simple but effective animated Loading Indicator which can easily ready to use integrated few lines

Yash Agarwal 95 Nov 15, 2022
:package: Android Parcelables made easy through code generation.

Parceler Have a question? Ask it on StackOverflow. Found an issue? Please report it. In Android, Parcelables are a great way to serialize Java Objects

John Ericksen 3.6k Dec 27, 2022