• Welcome to the Speedsolving.com, home of the web's largest puzzle community!
    You are currently viewing our forum as a guest which gives you limited access to join discussions and access our other features.

    Registration is fast, simple and absolutely free so please, join our community of 40,000+ people from around the world today!

    If you are already a member, simply login to hide this message and begin participating in the community!

Preview of my JavaScript Timer

K073

Member
Joined
Nov 12, 2009
Messages
28
Link:
http://k073.webs.com/timer.html
If the link fails to load, the server is updating and you have to wait a while before it can load again.

This timer is based on blah a.k.a. zzzonked's timer
Functions:
- tap [spacebar] to start timer and any key to stop
- the time is accurate because the timer is started when the spacebar is released and stopped whenever any button is pressed
- press '2' for 2x2 and again to enter BLD mode and again to get back to speed mode, press 3 for 3x3 and so on till 7x7. Press '9' for pyraminx
- press 'L' to view last scramble
- press 'Q' to display full details for each solve
- press 'P' to mark the current time as PLL skip and press 'O' for OLL skip
- press [escape] followed by [enter] to reset the times
- press 'D' to mark the current time as 'DNF' and press again to mark it as a +2 penalty and again to cancel the penalty
- hover on a time marked as 'DNF' to show the raw time
- press [delete] or [backspace] to delete current time
- click and drag the scramble preview to move the preview somewhere else because it might be blocking the scramble(or time)
- click on the time or press 'F' to toggle between full screen mode and normal mode(only applicable to browsers other than IE)
- click on the mean time or press 'M' to get the details including scrambles(suitable for doing small averages) and tap 'M' again to get full details without scrambles(suitable for big average attempts) so that you can copy them or whatsoever(only applicable in browsers other than IE too)
- click on the best/worst time(on the right side) or press 'Z' or 'X' to get the scramble for the relative scrambles
- click on the best/worst average of 5/12 time or press 'C', 'V', 'B', or 'N' to get the details so that you can copy them or whatsoever(only applicable in browsers other than IE too)
- click on the box displaying all the times to select and highlight all the texts, and press [CTRL]+[C] to copy them to the clipboard(after a box appears)(only applicable in non IE environment)
- If you really want it to be more "full screen" instead of seeing the navigation bars and title bars, press [F11]. If your browser supports full screen mode, the whole window will fill the screen.
Note: Google Chrome encouraged. IE disencouraged.


Previews:
file.php

Starting...
file.php

DNF function(forgot to show +2 penalty function), bracket best and worst time function, time of solve, number of solves, mean, average, standard deviation, current, best and worst average of 5 and 12.
file.php

In 3x3 Blindfolded mode. Display of memorization and execution time seperately, current time and date, full screen mode after clicking the time, position of scramble in full screen mode
file.php

Details of times after clicking on the mean time.
file.php

OLL, PLL and LL skip function, percentage of skips and DNFs, times for best average of 12 shown(click on the red 'X' to close the details box).
file.php

2x2 in blindfolded mode in non-full screen mode, scramble preview drag function.
 
Last edited:

K073

Member
Joined
Nov 12, 2009
Messages
28
last time I was just modifying the timer to suite my style. Now, since I made many changes, I'll just upload it and share with all the cubers.
 

Cride5

Premium Member
Joined
Jan 27, 2009
Messages
1,228
Location
Scotland
WCA
2009RIDE01
Nice!

If you could add in a <25 move random-state scrambler for 3x3 I'd be sold :D

EDIT: There's a bit of a bug with resizing the window in Firefox/Linux. The main timer disappears!
EDIT2: What's happening is when the window is reduced in size, no scroll bar appears. Pressing spacebar causes it to scroll to the bottom which hides the timer at the top. With no scroll bars there's no way to see the timer again, unless the window can be increased in size.

@ ShadenSmith (post below), are you talking about the bug where if you stop the timer and continue to hold it, the timer starts again when you let go? This is deffo another bug :/
 
Last edited:

K073

Member
Joined
Nov 12, 2009
Messages
28
random state scrambler would be too much for JavaScript.
the spacebar issue is a must because if not, when you hit the spacebar to stop the timer, and release immediately, the timer starts again.
I set the window to be opened in a pop up in full screen, why would you resize it?? just maximize the window and everything will be fine.
this timer is set to detect screen size and resize all element according to ratio given, so all the things will be crappy when you resize the window. that's the main reason I set it to pop a full screen window out.
 

Cride5

Premium Member
Joined
Jan 27, 2009
Messages
1,228
Location
Scotland
WCA
2009RIDE01
random state scrambler would be too much for JavaScript.

I don't think so. Not if move-count isn't a concern. Optimal random-state is deffo a bit of an ask, but something like Thistlethwaite certainly is not. The challenge is to have something which can generate scrambles of under 25 moves. I've already tried implementing the Kociemba 2-phase algorithm in js, but the memory consumption was too high - this is mainly because js doesn't offer good enough type control to store pruning tables efficiently. This could potentially be overcome by using bitwise operations to pack more data into 32-bit integers, but is a major faff!

With regards to resizing, if you want a program to be nice for its users its good to be flexible. Its perfectly reasonable to assume that folk may wish to have multiple windows open at once, or may be even working on a 640x480 display. Even if it can't show all elements, it should at least degrade in a reasonable manner. I personally use this scrambler along-side my timer..
 

Johannes91

Member
Joined
Mar 28, 2006
Messages
1,341
I've already tried implementing the Kociemba 2-phase algorithm in js, but the memory consumption was too high - this is mainly because js doesn't offer good enough type control to store pruning tables efficiently.
I came to the same conclusion a while ago. Even if it could be optimized enough to run acceptably on the best JS engines, it wouldn't work for people using older/worse browsers.

This could potentially be overcome by using bitwise operations to pack more data into 32-bit integers, but is a major faff!
Bitwise operations in JavaScript are *evil*! The language doesn't have an integer type - all numbers are double-precision (64-bit) floating point numbers. The bitwise operators convert their operands to integers, do their thing, then convert the result to floating point. They are quite unpredictable and rarely a good idea for anything.

Besides, all values are boxed (on most implementations) and an array of them takes much more space than needed. One way to store large tables could be to use a string, but I haven't tried it.

I think it would be fine to use an efficient program on the server and request new scrambles using AJAX when needed. If that annoys some people, you could print some (say, 100 or 1000) new scrambles in a JS array every time the page is loaded and only start making requests when those have been used.

With regards to resizing, if you want a program to be nice for its users its good to be flexible.
Definitely agreed.
 
Last edited:

Cride5

Premium Member
Joined
Jan 27, 2009
Messages
1,228
Location
Scotland
WCA
2009RIDE01
Bitwise operations in JavaScript are *evil*! The language doesn't have an integer type - all numbers are double-precision (64-bit) floating point numbers. The bitwise operators convert their operands to integers, do their thing, then convert the result to floating point. They are quite unpredictable and rarely a good idea for anything.

Damn I didn't realise that :eek: I assumed it did the same thing as other weakly typed languages, silently converting between types. Storing everything as 64-bit floats is just ridiculous, especially when bitwise operations insist on shrinking them to 32-bit ints. It basically means you can't do anything with bitwise operations unless you are happy to waste 32 bits! That is a serious flaw :eek:

Storing cube state in strings sounds like a good idea. It will reduce the memory footprint 4-fold (and possibly further if used in conjunction with bitwise operations), but at the same time will increase the overhead of read/writes. It may be worth it tho..
... thx for the pointer :)
 
Last edited:

K073

Member
Joined
Nov 12, 2009
Messages
28
Kociemba is written in JAVA not JavaScript! The source of the page is short because it loads Java instead of scripts to be executed by js engines. If I even put a Java applet into my timer, users will have to wait for a day to use my timer because they'll have to install latest Java.
Even if it doesn't require plugin installation, how am I going to make a Java applet interact with my scripts so that the script an fetch and save all the scrambles
 

Cride5

Premium Member
Joined
Jan 27, 2009
Messages
1,228
Location
Scotland
WCA
2009RIDE01
Kociemba is written in JAVA not JavaScript!

I've already tried implementing the Kociemba 2-phase algorithm in js, but the memory consumption was too high

Kociemba is currently implemented in C and Java. My attempt was a port of the Java implementation to Javascript. I say attempt because it failed for the reasons stated. Please don't accuse me of not knowing the difference between Java and Javascript, it's patronising.


how am I going to make a Java applet interact with my scripts so that the script an fetch and save all the scrambles
this is possible...
 
Last edited:

K073

Member
Joined
Nov 12, 2009
Messages
28
Kociemba is written in JAVA not JavaScript!

I've already tried implementing the Kociemba 2-phase algorithm in js, but the memory consumption was too high

Kociemba is currently implemented in C and Java. My attempt was a port of the Java implementation to Javascript. I say attempt because it failed for the reasons stated. Please don't accuse me of not knowing the difference between Java and Javascript, it's patronising.
ok, my bad...

how am I going to make a Java applet interact with my scripts so that the script an fetch and save all the scrambles
this is possible...
even if I can do this I won't because I would rather not to make it complex by adding Java applets. Even if I really add it, how am I supposed to get the scramble preview to function properly?? I'm bad at Java language
 

K073

Member
Joined
Nov 12, 2009
Messages
28
quote from http://cube.crider.co.uk/scrambler.html:
Scrambles are built by generating a statistically random cube state and using the Kociemba two-phase algorithm to find a solution to it. The inverse of the solution is then given as the scramble.
this means that the cube is scrambled, solved using 2-phase algorithm, inverse the solution to make it a scramble. the scramble is only shorten, not really necessary(except if you are not capable of doing 4/5 more moves)
 

Johannes91

Member
Joined
Mar 28, 2006
Messages
1,341
this means that the cube is scrambled, solved using 2-phase algorithm, inverse the solution to make it a scramble. the scramble is only shorten, not really necessary
The point isn't to have shorter scrambles, it's to have better scrambles. Making 25 random moves doesn't give a good distribution (some positions are significantly more probable than others), generating a random position does.

Anyway, I can't follow you. Did someone actually say you should add a Java applet to your scrambler? Cride just mentioned it as an example of another window that's nice to have open at the same time as a timer. Quote what you're replying to in the future unless it's obvious.
 

K073

Member
Joined
Nov 12, 2009
Messages
28
I'm not sold before pyraminx is added... (optimal scrambles too xD)
why is it so important to have pyraminx? it's a CUBE timer, not a puzzle timer. btw, that's not my point. I don't play pyraminx(or should I say "usually don't") and as I said previously, I modified a timer to suit my style, so non-cube is not necessary for me, yet.
Btw, if you really don't want any scramble previews, I can get pyraminx into it.
And, I'll consider optimal scrambler other times, now a little busy.

this means that the cube is scrambled, solved using 2-phase algorithm, inverse the solution to make it a scramble. the scramble is only shorten, not really necessary
The point isn't to have shorter scrambles, it's to have better scrambles. Making 25 random moves doesn't give a good distribution (some positions are significantly more probable than others), generating a random position does.

Anyway, I can't follow you. Did someone actually say you should add a Java applet to your scrambler? Cride just mentioned it as an example of another window that's nice to have open at the same time as a timer. Quote what you're replying to in the future unless it's obvious.
I mean, you won't even know whether a scramble is optimal or not and the pieces are in random positions or not, unless you are doing BLD. So, you won't even know whether it's really in random position or not unless you examine every pieces during your inspection time.
No one said that I should add Java applet, but it's indirectly calling me to do so, because something like Kocembia's two-phase algorithm can only easier to do with Java but not JavaScript. If I open that thing in a new window or pop up, I wouldn't even bother the scrambles there, because there's many things blocking in between Java and JavaScript.
 

Carrot

Member
Joined
Feb 9, 2009
Messages
1,910
WCA
2008ANDE02
YouTube
Visit Channel
I'm not sold before pyraminx is added... (optimal scrambles too xD)
why is it so important to have pyraminx? it's a CUBE timer, not a puzzle timer. btw, that's not my point. I don't play pyraminx(or should I say "usually don't") and as I said previously, I modified a timer to suit my style, so non-cube is not necessary for me, yet.
Btw, if you really don't want any scramble previews, I can get pyraminx into it.
And, I'll consider optimal scrambler other times, now a little busy.
Pyraminx is the puzzle I'm best at... so the timer I want to use should REALLY have pyraminx scrambles hehe :p
I don't need a scramble preview... just the scramble :p and as long as the move count is sub 20 I'm happy xD
 
Last edited:

Cride5

Premium Member
Joined
Jan 27, 2009
Messages
1,228
Location
Scotland
WCA
2009RIDE01
how am I going to make a Java applet interact with my scripts so that the script an fetch and save all the scrambles
this is possible...

http://java.sun.com/products/plugin/1.3/docs/jsobject.html

Allowing the script to interface with java means you can generate random-state scramblers relatively quickly, and would allow interfacing with a stackmat. it may be a better idea to just implement the whole timer program as a java applet, but doing so means having the java plugin is a necessity, rather than an optional extra for providing random state scrambles + stackmat interfacing.

I mean, you won't even know whether a scramble is optimal or not and the pieces are in random positions or not, unless you are doing BLD. So, you won't even know whether it's really in random position or not unless you examine every pieces during your inspection time.

Read this: http://www.speedsolving.com/forum/showthread.php?t=12969

And look up "Random Walk" and "Uniform Random Distribution"
 
Top