A Rubik's cube notation interpreter with conditionals and macros

73 views
Skip to first unread message

Daniikk1012

unread,
Oct 17, 2025, 7:22:16 PMOct 17
to forum
https://github.com/Daniikk1012/ROBOK-S

Glad to join the forum and share this project, cause I am quite proud of it. This is an idea I've had for a while, and decided, why not implement it in J?

This is my attempt at a natural-language-agnostic (somewhat) intuitive extension of the usual Rubik's cube notation (RLUFUB) that also features conditionals, so that it is possible to write a formula that solves the cube from any state. I wanted to experiment with J, so instead of settling with basic CLI, I implemented a GUI for this, and I think it turned out quite nice.

For the same reason I also decided to go with a parser combinator approach, as I couldn't find examples of people doing it in J (Only found recursive descent and regex parsers), so even if you're not interested in the Rubik's cube stuff, you might want to take a look at how well J's adverbs and conjunctions make parser combinators nice to work with.

What do you think of it?

Raul Miller

unread,
Oct 18, 2025, 10:28:55 AMOct 18
to fo...@jsoftware.com
Hmm...

As it is, there's an installation step which would be needed to
integrate your code into the J environment (because you use unadorned
load/require to bring in the scripts). And, this installation process
is currently not documented.

To make that documentation easier, maybe it would be acceptable to
include a bootstrap technique which would allow the scripts to be
loaded from anywhere?

In other words, at the beginning of each script which uses load or
require, add the following bit of bootstrap code:

here=: (4!:4 { [:4!:3 ''"_)&.<
here=: ({.~ 1 + <./@i:&'/\') here'here'

Then, instead of (for example) load'gui.ijs' use load here,'gui.ijs'

There are other approaches for this issue (for example, using the
package manager or using whichscript as defined in
misc/miscutils/utils), but at the moment, the above approach seems to
me to be the most straightforward.

(I have also occasionally been thinking about how something analogous
to this approach might be incorporated into the implementation of
load, but I have not been sufficiently motivated to accomplish that.)

Thoughts?

Thanks,


--
Raul
> To unsubscribe from this group and stop receiving emails from it, send an email to forum+un...@jsoftware.com.

Raul Miller

unread,
Oct 18, 2025, 12:15:10 PMOct 18
to fo...@jsoftware.com
I should add - what I am proposing here, with a little more work (need
a manifest, and some testing) could reduce "installation
documentation" to:

install'github:Daniikk1012/ROBOK-S'
load'Daniikk1012/ROBOK-S'

Though, of course, command line use would also require an additional
step (which would depend on the OS).

Thanks again,


--
Raul

Daniikk1012

unread,
Oct 18, 2025, 1:01:24 PMOct 18
to forum, Raul Miller
I haven't really thought of this as a loadable library (Except for jarser.ijs maybe), and instead more like a runnable application for people who are not necessarilly using J themselves, though I haven't found a nice way of packaging it that avoids obligating people to install J on their system, so I guess it doesn't do that job very well.

But now that you suggested it, I see it might also be useful to be able to load it from a J session, so I will definitely try converting it into a proper J addon.

I will probably also use the bootstrap solution though, for running it as an app, without installation. I also think you can avoid having to pollute the locale by doing this:

here =. ({.~1+<./@i:&'/\')>(4!:4''){4!:3''

Since 4!:4 given an empty array returns the index of the script currently being loaded. Surprised I haven't seen this kind of bootstrapping before, probably because everyone is actually using the package manager.

Thanks for the feedback,

Daniyar
суббота, 18 октября 2025 г. в 21:15:10 UTC+5, Raul Miller:

Daniikk1012

unread,
Oct 18, 2025, 4:03:31 PMOct 18
to forum, Daniikk1012, Raul Miller
Yay, it is now an addon! Was a bit surprised that numbers are not allowed in the top folder name for the addon. So instead of just removing numbers and settling for "daniikk", I decided to follow the guidelines and choose a category (I couldn't, so I went with "misc").
суббота, 18 октября 2025 г. в 22:01:24 UTC+5, Daniikk1012:

chris burke

unread,
Oct 18, 2025, 11:12:11 PMOct 18
to fo...@jsoftware.com
The addon installed fine. To run the app:

load '~addons/misc/roboks/main.ijs'

Had you used roboks.ijs instead of main.ijs as the entry script (i.e.
with the same name as the folder), you could load as:

load'misc/roboks'

Also, you could have used your name as the category, in which case the
load would be:

load'daniikk/roboks'

In the gui, it would be nice to have (at least for this audience) a
button to show the ide.

The code looks nicely written, though I don't understand the long
first lines of functions like name, group and scope. What is the point
of these lines?

chris burke

unread,
Oct 19, 2025, 3:53:54 AMOct 19
to fo...@jsoftware.com
As regards loading the several source scripts in the addon - you can
create a Jqt project that assembles the source scripts into a single
script for distribution, so the load/require calls can be removed from
the scripts. The addon manifest then includes just this single script.

For example, see https://github.com/jsoftware/convert_numpy.

Daniikk1012

unread,
Oct 19, 2025, 4:53:26 AMOct 19
to forum, chris burke
Thanks for the feedback! I have already included roboks.ijs in the project, but it only loads the libraries. If you want to use load GUI from J Qt session, you should use

load'misc/roboks/gui'

This will keep the IDE window visible.

main.ijs is still there only to run it directly, without loading, so it hides the IDE window. It is also the only way to access the CLI because it doesn't make sense to load it, as command line arguments are required.

The long lines, if I understood what you mean correctly, are just me trying to separate the parsers into smaller parts so that the lines don't become too big, and most of the time the splits are arbitrary (I tried to give them meaningful names where I could). Though "group" only consist of a single line, but maybe you were talking about "conditions"? Hopefully the "..." proposition will make it in soon, cause that would simplify the code a lot.

As for the build step suggestion, I am personally not a fan of having a build process in interpreted languages, so I will probably leave it as is, but thanks for the suggestion.

воскресенье, 19 октября 2025 г. в 12:53:54 UTC+5, chris burke:
Reply all
Reply to author
Forward
0 new messages