badmephisto
Veteran
For the past few days I have been working on a program that would analyze algorithms and output an expected time of execution. This idea is of course by no means unique, but as far as I am aware, even though there have been some attempts at this, noone has actually made or published anyhting useful.
The program I made is called gripper. It takes as input an algorithm and outputs expected time of execution (which of course is relative per cuber, but all that matters are the relative ratios of the times, not the actual numbers). It does this by trying out different grips on the cube, and following through the notation recursively to find best ways to essentially grip the cube such that an algorithm is executed quickly and efficiently.
I am currently working fulltime, parttime, and taking courses at the university, so my time is extremely limited and I will not have time to make any significant changes to the program. So I decided to just release the program as is, in its partly-functional form, and I will also make the code available on SVN. So if you know Python, you are very welcome to get the code, change it up, and extend its features. I know many of you here are programmers and I hope you agree that this kind of program would be extremely useful for speedcubing, so I hope we can get together and make something work. The idea of dumping Opticubes output into this program and having the computer do analysis for us is the optimal goal here.
The code is very well commented because I love commenting my code. It helps me stay organized. Its also very short I would say, and very easy to understand. It is not fastest as you will notice, but my main concern was functionality, not time bounds. At least for now.
Here is what I have so far: (So in particular note that I can already analyze opticubes output!)
- I can analyze any algorithm containing standard notation RLFBUD. I also support rlfbud middle layer turns but I assume that the cost of executing r is the same as that of executing R and so on. This seems like a pretty good approximation to me so far.
Things not supported:
- Cube rotation xyz
- Middle slices MSE (current implementation is sort of a hack)
Here are 3 things to still be implemented that I have thought of:
- add support for xyz rotations. This requires some manual labor as you have to define the transformation of notation for each rotation x,x2,x', y, y2, y', z, z2, z'
- it is clear that a cube rotation can dramatically decreasse time of execution by converting B's to R' and stuff like that. We need a program that takes in algorithm like (A1 A2 A3 .... An) and outputs an equivalent algorithm with cube rotations in between notation. The idea is that we will generate all possible cube rotations that can be applied to speed up the algorithm, and then analyze them all and have the program filter out non-beneficial rotations. So example of output would be in our case (x B1 B2 B3 B4 B5 y' z B6 ... Bn). This is done for the obvious reason that alg may be flagged by the program as slow, but if you enter the right rotation somewhere, it may suddenly be the best alg. Note that there may be a LOT of these variations. Exponentially many in fact. There may have to be some heuristics put in that prune the search space, or maybe we only want to generate a small subset of variations that "make sense", but someone would have to come up with a mathematical formula for that. For example if next letter is B, then maybe it makes most sense to have a cube rotation y, because then that B becomes R, etc.
- there also has to be code that will take the alg with cube rotations and postprocess it in the sense that we may have created some double layer turns there which are much faster than cube rotation and a move. Take as an example a case where somewhere in the alg you have "L x". Well this is nothing else than just r... but clearly r is MUCH faster than L x.
I hope that in this thread we can lead a discussion on both implementation details and conceptual ideas about the program and its future.
SVN Info:
Here is url and user and pass for a shared account to the repository if you just want to check it out. If you decide that you would like to try and do some development, you can msg me here, or through private message, or email, and i will create you an account
url: svn://badmephisto.mine.nu/gripper
user: others
pass: gripper
Download Info:
Source code (Python 2.4): http://badmephisto.mine.nu/gripper_release/src.zip
Binaries (exe): http://badmephisto.mine.nu/gripper_release/bin.zip
Wiki page for the project: http://badmephisto.mine.nu/gripperwiki/
Example usage:
gripper.exe R U R' U' R' F R2 U' R' U' R U R' F'
("G0 R U R' U' G1 R' F R2 U' R' U' R G1 U R' F' ", 1.9200000000000004)
Means hold cube in Grip 0, execute RUR'U' then regrip to 1, execute ... See Wiki for description of grips. Basically Grip 0 means right hand thumb is on D, Grip 1 is thumb on F, and Grip 2 is thumb on U. Left hand always just holds the cube while right hand does the work.
(tperm.txt is a file containing all algorithms from opticubes for the T permutation, so about 100 algs. Following prints top 5 best algs)
gripper_batch.exe tperm.txt 5
("R U R' U' R' F R2 U' R' U' R U R' F'\n", "G0 R U R' U' G1 R' F R2 U' R' U' R G1 U R' F' ", '1.92')
("F R U' R' U R U R2 F' R U R U' R'\n", "G0 F R U' R' G1 U R G1 U G2 R2 F' R U R U' R' ", '2.20')
("R2 U' R2 D B2 L2 U L2 D' B2 U\n", "G0 R2 U' R2 D B2 G1 ! G0 L2 U L2 D' B2 U ", '2.37')
("R2 U' R2 D B2 L2 U L2 D' B2 U\n", "G0 R2 U' R2 D B2 G1 ! G0 L2 U L2 D' B2 U ", '2.37')
("D' R2 U R2 U' R2 F2 U' F2 D R2\n", "G1 D' G0 R2 G1 U G0 R2 U' R2 F2 U' F2 D R2 ", '2.41')
First entry is the original algorithm as appears in the file
Second entry is the suggested execution of the algorithm. The Exclamation marks (!) mean that you should switch hands... i.e. execute the rest with your left hand, right hand holds the cube steady.
Third entry is the cost
(Also note that the algorithm that we all use as t-perm indeed comes up all the way at the top as the best algorithm. So gripper agrees with us... phew
)
The program I made is called gripper. It takes as input an algorithm and outputs expected time of execution (which of course is relative per cuber, but all that matters are the relative ratios of the times, not the actual numbers). It does this by trying out different grips on the cube, and following through the notation recursively to find best ways to essentially grip the cube such that an algorithm is executed quickly and efficiently.
I am currently working fulltime, parttime, and taking courses at the university, so my time is extremely limited and I will not have time to make any significant changes to the program. So I decided to just release the program as is, in its partly-functional form, and I will also make the code available on SVN. So if you know Python, you are very welcome to get the code, change it up, and extend its features. I know many of you here are programmers and I hope you agree that this kind of program would be extremely useful for speedcubing, so I hope we can get together and make something work. The idea of dumping Opticubes output into this program and having the computer do analysis for us is the optimal goal here.
The code is very well commented because I love commenting my code. It helps me stay organized. Its also very short I would say, and very easy to understand. It is not fastest as you will notice, but my main concern was functionality, not time bounds. At least for now.
Here is what I have so far: (So in particular note that I can already analyze opticubes output!)
- I can analyze any algorithm containing standard notation RLFBUD. I also support rlfbud middle layer turns but I assume that the cost of executing r is the same as that of executing R and so on. This seems like a pretty good approximation to me so far.
Things not supported:
- Cube rotation xyz
- Middle slices MSE (current implementation is sort of a hack)
Here are 3 things to still be implemented that I have thought of:
- add support for xyz rotations. This requires some manual labor as you have to define the transformation of notation for each rotation x,x2,x', y, y2, y', z, z2, z'
- it is clear that a cube rotation can dramatically decreasse time of execution by converting B's to R' and stuff like that. We need a program that takes in algorithm like (A1 A2 A3 .... An) and outputs an equivalent algorithm with cube rotations in between notation. The idea is that we will generate all possible cube rotations that can be applied to speed up the algorithm, and then analyze them all and have the program filter out non-beneficial rotations. So example of output would be in our case (x B1 B2 B3 B4 B5 y' z B6 ... Bn). This is done for the obvious reason that alg may be flagged by the program as slow, but if you enter the right rotation somewhere, it may suddenly be the best alg. Note that there may be a LOT of these variations. Exponentially many in fact. There may have to be some heuristics put in that prune the search space, or maybe we only want to generate a small subset of variations that "make sense", but someone would have to come up with a mathematical formula for that. For example if next letter is B, then maybe it makes most sense to have a cube rotation y, because then that B becomes R, etc.
- there also has to be code that will take the alg with cube rotations and postprocess it in the sense that we may have created some double layer turns there which are much faster than cube rotation and a move. Take as an example a case where somewhere in the alg you have "L x". Well this is nothing else than just r... but clearly r is MUCH faster than L x.
I hope that in this thread we can lead a discussion on both implementation details and conceptual ideas about the program and its future.
SVN Info:
Here is url and user and pass for a shared account to the repository if you just want to check it out. If you decide that you would like to try and do some development, you can msg me here, or through private message, or email, and i will create you an account
url: svn://badmephisto.mine.nu/gripper
user: others
pass: gripper
Download Info:
Source code (Python 2.4): http://badmephisto.mine.nu/gripper_release/src.zip
Binaries (exe): http://badmephisto.mine.nu/gripper_release/bin.zip
Wiki page for the project: http://badmephisto.mine.nu/gripperwiki/
Example usage:
gripper.exe R U R' U' R' F R2 U' R' U' R U R' F'
("G0 R U R' U' G1 R' F R2 U' R' U' R G1 U R' F' ", 1.9200000000000004)
Means hold cube in Grip 0, execute RUR'U' then regrip to 1, execute ... See Wiki for description of grips. Basically Grip 0 means right hand thumb is on D, Grip 1 is thumb on F, and Grip 2 is thumb on U. Left hand always just holds the cube while right hand does the work.
(tperm.txt is a file containing all algorithms from opticubes for the T permutation, so about 100 algs. Following prints top 5 best algs)
gripper_batch.exe tperm.txt 5
("R U R' U' R' F R2 U' R' U' R U R' F'\n", "G0 R U R' U' G1 R' F R2 U' R' U' R G1 U R' F' ", '1.92')
("F R U' R' U R U R2 F' R U R U' R'\n", "G0 F R U' R' G1 U R G1 U G2 R2 F' R U R U' R' ", '2.20')
("R2 U' R2 D B2 L2 U L2 D' B2 U\n", "G0 R2 U' R2 D B2 G1 ! G0 L2 U L2 D' B2 U ", '2.37')
("R2 U' R2 D B2 L2 U L2 D' B2 U\n", "G0 R2 U' R2 D B2 G1 ! G0 L2 U L2 D' B2 U ", '2.37')
("D' R2 U R2 U' R2 F2 U' F2 D R2\n", "G1 D' G0 R2 G1 U G0 R2 U' R2 F2 U' F2 D R2 ", '2.41')
First entry is the original algorithm as appears in the file
Second entry is the suggested execution of the algorithm. The Exclamation marks (!) mean that you should switch hands... i.e. execute the rest with your left hand, right hand holds the cube steady.
Third entry is the cost
(Also note that the algorithm that we all use as t-perm indeed comes up all the way at the top as the best algorithm. So gripper agrees with us... phew
Last edited:
