Stefan
Legend
I don't know JS, sorry.That was encouragement for the people who are making it shorter.
Feel free to do it in any other language.
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
I don't know JS, sorry.That was encouragement for the people who are making it shorter.
According to that, that single line is unnecessary, but when you remove it (which is ok since it's unnecessary), you don't have any line anymore, and that old saying still claims there's an unnecessary line of code. So obviously that old saying is wrong.
http://jsfiddle.net/Yx8Wz/5/
I made it graphical with css sprites. Not shorter but more interesting than the work I'm supposed to be doing right now.
It just replaces the text with an image. It might make it easier for someone to actually solve.
Coooool. I like it!
This is certainly a stronger requirement than the original one. No sliding puzzle sim posted so far has even been close to random state scrambling.Let me make this a proper challenge by defining the requirements:
- Must look like Tom's original or "equivalent" (you can for example make it graphical, or use 10..15 instead of A..F)
- Must have reasonably laid out up/down/left/right keys working like Tom's original (or use the mouse or whatever in a convenient way).
- Must have one-key/click random state scrambling.
Of course it's the same. They're both puzzles that don't scramble themselves. Real 15 puzzles don't scramble themselves either, you know. How can you call it a proper real puzzle if it doesn't even have random-state scrambling?!No. That's not the same. [...]
- Scrambling in our cube sim still is proper! Holding a key for like five seconds or randomly hitting keys for five seconds is both reasonably convenient and provides reasonably good scrambles. Not the case for the 15-puzzle, where you need a lot more random moves for a good quality scramble.
Looks pretty nice. I did a 3:58.95 solve on it.http://jsfiddle.net/Yx8Wz/5/
I made it graphical with css sprites. Not shorter but more interesting than the work I'm supposed to be doing right now.
It just replaces the text with an image. It might make it easier for someone to actually solve.
So, no requirement that the sim "really" simulate the cube? i.e., the ability to rotate any face...
You can rotate any face with combinations of multiple keypresses in any of the existing sims presented.
This is certainly a stronger requirement than the original one.
No sliding puzzle sim posted so far has even been close to random state scrambling.
Of course it's the same.
Real 15 puzzles don't scramble themselves either, you know.
While I agree a 15-puzzle takes longer to scramble than a 3x3x3, you can still scramble the puzzle completely by mashing random keys. It just might take longer.
I made one with a 9999-move one-key scrambler and the old visuals, but it's 271 characters now (plus <pre> tag): http://jsfiddle.net/pq6VK/4/
Can we get a definition of "sim" as it is being referenced in this thread?
Simulator for the Rubik's Cube.
Not surprising at all, given that we are trying for as few characters as possible. Because of those pesky \ns I can't really think of any short way to actually generate a random state. You're free to try yourself, and I'd like to see your result.Really? That's rather surprising, given how easy it is. Basically just spam a random permutation and fix parity (or spam again until parity is ok, it's a 50/50 chance after all)
It looks like Chrome wasn't accepting function(e)d(e.keyCode%5) - it wanted some {}s. Here's a fixed version with 272 characters: http://jsfiddle.net/pq6VK/5/Doesn't work for me. The result screen is empty and stays empty when I press keys (tested in Chrome and IE).
Not surprising at all, given that we are trying for as few characters as possible. Because of those pesky \ns I can't really think of any short way to actually generate a random state. You're free to try yourself, and I'd like to see your result.
It looks like Chrome wasn't accepting function(e)d(e.keyCode%5) - it wanted some {}s. Here's a fixed version with 272 characters: http://jsfiddle.net/pq6VK/5/
PS: can I at least get a "nice job" for completely optimizing the 15 puzzle myself?
Not surprising at all, given that we are trying for as few characters as possible.
PS: can I at least get a "nice job" for completely optimizing the 15 puzzle myself?
Nah, I was specifically talking about code-golfed ones (that is, ones in this thread). The ones people use for speedsolving are, unsurprisingly, random-state.Yes surprising. Judging by what you're saying now, I guess your "No sliding puzzle sim posted so far" meant "posted in this thread". That was not at all clear, as I think there just had been Thom's and yours and both were 15-puzzles while "sliding puzzle" is more general. So I thought you meant in general (which should've been clear by me pointing to one outside?). And there it is surprising (or rather, wrong).
I think Carson deserves better than that. I actually agree with what I think he means. This cube simulator doesn't simulate the cube. It doesn't simulate an L turn, for example, which is a fundamental move on the real cube. We simulate that turn. But that's not the same. Essentially it's not a simulator for the Rubik's Cube. If it for example allowed <r,u,f> turning, we also wouldn't call it a Rubik's Cube simulator but an <r,u,f> solving simulator.
I agree that /we/ are simulating the turn, but disagree that it is not a simulator.
For me, it's good enough that it reaches every position and can be fully scrambled and solved (also that is has some kind of visual output).