# ACube.js



## Lucas Garron (Apr 5, 2013)

Remember when this was impossible?

http://www.cubing.net/ACube.js/

Built using Josef Jelinek's ACube, Ryan Heise's frontend, and Emscripten.
Most of the time was spent making it easy to use, rather than simply getting it to work.


----------



## Renslay (Apr 5, 2013)

Wow. I'm amazed. Good job, and thanks! I waited for such a frontend so long. 

It that works only in online, or has a downloadable version?


----------



## Lucas Garron (Apr 5, 2013)

Renslay said:


> It that works only in online, or has a downloadable version?



It works offline, but it won't work correctly in Chrome if you just save the webpage.

(If you're just worried about not always having internet access, http://www.cubing.net/ACube.js/inc/offline.html might be enough.)


----------



## Renslay (Apr 5, 2013)

Thanks!


----------



## qqwref (Apr 6, 2013)

Impossible? I dunno about that. But I think anyone would have expected a purely-javascript optimal solver to be pretty slow, and indeed, it is :|

It's definitely a cool idea though. I like that the graphical editor is combined with ACube itself.


----------



## Lucas Garron (Apr 6, 2013)

qqwref said:


> Impossible? I dunno about that. But I think anyone would have expected a purely-javascript optimal solver to be pretty slow, and indeed, it is :|



I suppose this was always possible using Java. But the bindings were annoying, slow, and unsafe (browsers are slowly refusing to load Java).

I'm not sure about slow, though. Reaching depth 13 on "UF FD FR UL BL DR DB BU LD FL BR RU FLD FRD FUR LFU BDL BLU BRU RDB" (the default text box input, cube-in-cube-in-cube) takes under 6 seconds in Firefox Nightly, which is actually *faster* than ACube3.1.jar. That's because Firefox Nightly just started supporting asm.js -- the reason I tried this.

Chrome takes about twice as long right now, which is still pretty fast for Javascript. I hope it'll have asm.js soon.




qqwref said:


> It's definitely a cool idea though. I like that the graphical editor is combined with ACube itself.


Stachu had actually done this in a .jar before: http://www.speedsolving.com/forum/showthread.php?30714-aCube-frontend-v3-4-release!-(beta)
Pure Javascript opens up a lot of interesting possibilities, though. I won't have much time to work on this, but perhaps someone else can take the idea and run.


----------



## littlewing1208 (Apr 6, 2013)

Server side javascript (a la nodejs) would be incredibly fast for the computational aspects of this app and just leave the web portion for collecting user input and rendering results. I'm sure a lot of of the computation being done in the included scripts (could I get the source please?) are not particularly efficient for client side computation.

Edit: derp just saw the github link on the page


----------



## Lucas Garron (Apr 6, 2013)

littlewing1208 said:


> Server side javascript (a la nodejs) would be incredibly fast for the computational aspects of this app and just leave the web portion for collecting user input and rendering results. I'm sure a lot of of the computation being done in the included scripts (could I get the source please?) are not particularly efficient for client side computation.
> 
> Edit: derp just saw the github link on the page



What do you mean with "incredibly fast"? It can't be significantly faster than in the browser, and doing it in the browser doesn't cost the server anything (and can be done offline, doesn't involve sharing what you're working on, etc.). The script runs in a web worker, so it's not like input and getting the results are being slowed down.

If you have any ideas, feel free to play with the source. There are a lot of useful things to be done, I just don't have time for them.


----------



## qqwref (Apr 6, 2013)

Lucas Garron said:


> I'm not sure about slow, though. Reaching depth 13 on "UF FD FR UL BL DR DB BU LD FL BR RU FLD FRD FUR LFU BDL BLU BRU RDB" (the default text box input, cube-in-cube-in-cube) takes under 6 seconds in Firefox Nightly, which is actually *faster* than ACube3.1.jar.


Hang on here. You're both (a) using a beta version of Firefox which is presumably way faster than normal, and (b) using Java ACube, which may be quite a bit slower than the normal one. I know the normal ACube is really fast, and when I ran this on my Firefox it ran quite slowly. So to me it sounds like your test skews the results greatly and is applicable to almost nobody's normal setup.


----------



## littlewing1208 (Apr 6, 2013)

I don't know the source, but if people are implying that it isn't fast enough, I'm saying that most people are using web books or tablets or modestly powered laptops/desktops so if an AWS C2.3XLARGE EC2 instance was running a nodejs server, it'll probably chomp through the computation in a few orders of magnitudes less time than with client side js in a browser.

But like you mentioned, it's not as 'offline' friendly and someone has to pay/maintain/host for it . I've been wanting a good reason to place with node so I might play around with this and do some benchmarking.


----------



## Lucas Garron (Apr 6, 2013)

qqwref said:


> Hang on here. You're both (a) using a beta version of Firefox which is presumably way faster than normal, and (b) using Java ACube, which may be quite a bit slower than the normal one. I know the normal ACube is really fast, and when I ran this on my Firefox it ran quite slowly. So to me it sounds like your test skews the results greatly and is applicable to almost nobody's normal setup.



Well, (a) hopefully it'll be out of beta soon enough. (And anyone can try it if they want.)
(b) Just tried the direct C++ program from a fresh build. You're right, it's closer to 4-5 seconds.

However, I'm getting a factor of 2-3 on Chrome stable, which counts as "normal setup" for quite a few people. So, we'll see. I'll be watching the performance of browsers on this as they move towards asm.js.


----------



## pjk (Apr 6, 2013)

Very nice.


----------



## Lucas Garron (Apr 12, 2013)

Renslay said:


> It that works only in online, or has a downloadable version?



Forgot to mention, but there's a standalone version: http://www.cubing.net/ACube.js/ACube.js-in-a-box.zip


----------



## tim (Apr 12, 2013)

littlewing1208 said:


> I don't know the source, but if people are implying that it isn't fast enough, I'm saying that most people are using web books or tablets or modestly powered laptops/desktops so if an AWS C2.3XLARGE EC2 instance was running a nodejs server, it'll probably chomp through the computation in a few orders of magnitudes less time than with client side js in a browser.



Why would you compile c++ code to javascript and then run it on a server using node.js?
Btw. it takes around 12s for the default input on my 2.5 year old laptop using Chrome (so, no asm.js).

Nice job, Lucas! Starred it on Github. 
How much actual work did you have to put into it? In other words: How well does Emscripten work? (edit: Just found this. That's impressive!)


----------



## littlewing1208 (Apr 12, 2013)

Eh, I wasn't familiar with ACube until I found this thread and didn't know it was a conversion from c++ to js with Emscripten. I thought it was purely a client side js app that could be converted into a lightweight webui with the computationally heavy backend code running on a nodejs server.


----------



## Ruxpin (Apr 29, 2013)

This is such a nice resource to have, thank you for assembling and posting it for everybody! I've had a great desire to familiarize myself with ACube for some time as it appears to have tremendous potential. Unfortunately I have a pair of mild mental conditions that just refuse to allow me any functional interactions with applications that rely heavily on unfamiliar syntax.

Now that I've actually spent a few moments playing with the program I've got a couple questions to ask. 
-First am I correct in assuming that Face Turn Metric is equivalent to the Half Turn Metric described by the Speedsolving Wiki? 
-Can I restrict and/or filter the algorithm from calculating and/or displaying moves I do not desire such as turns of the Back face or the E slice?
-Can the software make use of double layer, or "wide" face turns? (The lack of this option alone has all but eliminated my use of Cube Explorer.)
-Could I possibly permit the program's use of a given move while simultaneously preventing the use of it's direct inverse? i.e. could I Allow: U2 while I Prevent: U'2 ?

I read the Advanced Instructions which, while certainly insightful, left me feeling largely uninformed as to the limitations and potential use of many advanced settings to which I've long desired access. I attempted a couple of manual searches to find a well made guide or tutorial but the only results I found were problematic for me due to the non-standard syntax and commands, so I apologize if all this information is readily covered elsewhere.

Thank you for your time and effort.
~Ruxpin


----------



## Kirjava (Apr 29, 2013)

This is awesome. Thanks Lucas.


----------



## Bhargav777 (Apr 29, 2013)

Hey Lucas, I'm still waiting for you to make a mobile version of the alg.garron.us link. I use galaxy S2 btw. I think I bugged you sometime back about this in the "which software do you need" thread. Sorry but I feel really bad when Brest reconstructs cool solves and I don't have a cube in my hand but still wanna watch what had really happened in the solve, through mobile.


----------



## Lucas Garron (Apr 29, 2013)

Bhargav777 said:


> Hey Lucas, I'm still waiting for you to make a mobile version of the alg.garron.us link. I use galaxy S2 btw. I think I bugged you sometime back about this in the "which software do you need" thread. Sorry but I feel really bad when Brest reconstructs cool solves and I don't have a cube in my hand but still wanna watch what had really happened in the solve, through mobile.



Yeah, this is a very important use case for me, but I've been waiting for a hackathon to take the time to plan and implement the important parts. It's definitely at the top of my side project lists for the summer.


----------



## jfly (Apr 30, 2013)

Lucas Garron said:


> Yeah, this is a very important use case for me, but I've been waiting for a hackathon to take the time to plan and implement the important parts. It's definitely at the top of my side project lists for the summer.



I'm so there if you'd like a partner =).


----------



## Bhargav777 (May 1, 2013)

Awesome!   please please, do message me immediately after you do, I seriously don't want to miss this at any cost.  
Thanks!


----------



## Lucas Garron (Nov 27, 2013)

qqwref said:


> Lucas Garron said:
> 
> 
> > I'm not sure about slow, though. Reaching depth 13 on "UF FD FR UL BL DR DB BU LD FL BR RU FLD FRD FUR LFU BDL BLU BRU RDB" (the default text box input, cube-in-cube-in-cube) takes under 6 seconds in Firefox Nightly, which is actually *faster* than ACube3.1.jar.
> ...



I just tried this again in Chrome out of curiosity, and I'm getting 7 to 7.5 seconds for depth 13.
I think it's fair to say now that the browser itself is not the limit.


----------

