• 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!

Software: kubesolver - easy algorithm generator for 3x3x3

brododragon

Member
Joined
Dec 9, 2019
Messages
2,274
Location
Here
There is a new update 1.0.5. It addressees some of the suggestions. Also there is a new website address kubesolver.com

- Fix a problem when some sequences were not printed. (sequences that had equivalent partial sequences to some other sequences)
- Fix a problem with moves that don't change cube state
- Add new option max-depth-after-first-match (da)
- Add option to set all options as commands rather than commmand line argument. Now it's possible to set max nunber of moves or depth in config.
Example:
set n 10 - print first 10 sequences found
set da 1 - only searcg sequences at most 1 move longer than the shortest sequence found
set d 14 - only search sequences at most 14 moves long.

@brododragon. Sorry I missed your previous post somehow. Yes, the program can brick your computer if you try to calculate a full cube from the beginning. The program isn't meant for that honestly. You can use a the solve_two_phase command for that. But it should rather be used for cases which can be solved either in a small number of moves or with small number of generators.



You can;t solve that case with RU because it affects edges in D layer. My program isn't designed to gracefully fail on impossible inputs.
Ok, thanks.

What do you think about my idea?
A command to define a case but without a few pieces, to which the program would gen algs for all possible cases. I might write a seudo-interface later.


Here's some suedo code (at da 1):
init_empty_cube
add_f2l
add_edges_orientation
add_corners_orientation
solve [CO]
1:
...
2:
...
3:
...
4:
...
5:
...
6:
...
7:
...


(gens all CO cases)
 

kubesolver

Premium Member
Joined
Nov 15, 2019
Messages
425
Ok, thanks.

What do you think about my idea?

A command to define a case but without a few pieces, to which the program would gen algs for all possible cases. I might write a seudo-interface later.

Here's some suedo code (at da 1):

(gens all CO cases)

Yes and no.

I won't add it to the kubesolver itself, but the the main advantage of command-line programs is that they have command-line interface and can easly interact with other programs so it's relatively straightforward to write a program to generate those cases and that will call kubesolver many times to solve all these cases.
I will prepare an example of how to do that for your particular case (if I understand correctly your example is solving second step of 2-look OLL)

p.s. it's "pseudo code" but the P is silent because english makes no sense.
 

N's-cvt

Member
Joined
Feb 5, 2020
Messages
119
I think I mentioned this suggestion before but if you could include movelimits like (R2 2 times) or (F2 0 times) it would definitely become my main generator but as of now it's so tedious to have the program generate 100 cases and then have to go into a google doc and take out all the algs with an F2 (not a fan of those). I think it would be a great tool to add in V-K.1.0.6
 

kubesolver

Premium Member
Joined
Nov 15, 2019
Messages
425
How could you handle inspection rotations so that you can generate for any particular cross colour for example and have that on the D face ?

So I set up the cross on the bottom, do the scramble oriented in a way that the cross to the solve is on the bottom and solve it.
Code:
init_empty_cube
add_edge DF
add_edge DB
add_edge DR
add_edge DL
[reverse orientation]
[scramble_moves]
[orientation]
solve
If I want a particular orientation for example solve cross for D' U2 L2 D L2 B2 U B2 F2 D' B L2 B2 D2 L' D F' D2 U2 R' with orientation (z') I would do
Code:
init_empty_cube
add_edge DF
add_edge DB
add_edge DR
add_edge DL
z
D' U2 L2 D L2 B2 U B2 F2 D' B L2 B2 D2 L' D F' D2 U2 R'
z'
solve
Will you make an online version because I can't run either on Chromebook
I don't know anything about Chromebook limitations. I don't intend on making an online version.
If there is a gcc and make on a chromebook then you could compile it there.

I think I mentioned this suggestion before but if you could include movelimits like (R2 2 times) or (F2 0 times) it would definitely become my main generator but as of now it's so tedious to have the program generate 100 cases and then have to go into a google doc and take out all the algs with an F2 (not a fan of those). I think it would be a great tool to add in V-K.1.0.6
I will most likely not add it to the kubesolver solver. I think generation of algorithms and filtering is a different task.
However I plan to add more tools (and hope that other would do as well) that use kubesolver to do more complicated tasks.
It's already possible to write a simple script that in one go generates algs in kubesolver and ranks them with algexplorer and I want to encourage this kind of usecases rather than adding more functionality to kubesolver.

filtering out F2 can be done from a command line with a simple `grep -v F2`
Code:
$ ./kube_solver.out --silent -da 0 < in.txt
r2 D' r D F' R F2 R' F' D' r
r2 R U' F' U r2 R' U F U F'
U2 F' U' r' F U' r F r' U r
U' r' U' r F' r' U2 r' F' r2 F
U R' U' F' U r' D R D' r F
U2 F R' U' R2 U' R2 U2 R U' F'
R U' F' r2 U' F U r2 F U' R'
r' F2 r F2 R' F2 r U R U' r'
r2 D' r U r' D r2 U' r' U' r
U2 F' r' D R' D' r2 U' r' F2 R
U2 F2 R2 F U' r' F r F' R2 F2
$ ./kube_solver.out --silent -da 0 < in.txt | grep -v F2
r2 R U' F' U r2 R' U F U F'
U2 F' U' r' F U' r F r' U r
U' r' U' r F' r' U2 r' F' r2 F
U R' U' F' U r' D R D' r F
U2 F R' U' R2 U' R2 U2 R U' F'
R U' F' r2 U' F U r2 F U' R'
r2 D' r U r' D r2 U' r' U' r


What I mean is for example I won't add a specialized cross solver to kubesolver, but I might add a tool to generate crosses that uses kubesolver in the backend.

a python prorgam
Code:
import scramble_util
from solver import Solver
import sys
cross_orientations = [
    "", # white on top
    "x", # green on top
    "x2", # yellow on top
    "x'", # blue on top
    "z", # orange on top
    "z'", # red on top
]

scramble_moves = " ".join(sys.argv[1:])
for orientation in cross_orientations:
    with Solver("kube_solver.exe", ["--silent"]) as solver:
        solver.write_line("set da 0") # find only optimal crosses
        solver.write_line("init_empty_cube")
        solver.write_line("add_edge DF")
        solver.write_line("add_edge DB")
        solver.write_line("add_edge DR")
        solver.write_line("add_edge DL")
        solver.write_line(scramble_util.reverse_move(orientation))
        solver.write_line(scramble_moves)
        solver.write_line(orientation)
        solver.write_line("solve")
        solver.end_of_input()
        print("optimal crosses for orientation " + orientation)
        for line in solver.read_all_lines():
            print(orientation + " " + line.strip())
an output:
Code:
python cross_finder.py "D' U2 L2 D L2 B2 U B2 F2 D' B L2 B2 D2 L' D F' D2 U2 R'"
optimal crosses for orientation
L2 D2 F D L R
B' L2 B D' L R
D' R D F L2 D'
D' R D L2 F D'
L2 D' R D F D'
optimal crosses for orientation x
x B F2 D B F D
x F' D U' L2 B F'
x U' R2 F' D L2 F'
x U' F' R2 D L2 F'
x B2 F' D' B' F' D2
x F U' L2 R2 B' F'
x F' L2 B2 D B' F'
x B2 U' R2 F' D F2
x B2 U' F' R2 D F
optimal crosses for orientation x2
x2 B' U L R2 F
x2 B' L U R2 F
optimal crosses for orientation x'
x' F2 D L D2 B'
x' D' U L2 B' R'
x' D' U B' L2 R'
x' D' B' U L2 R'
x' D' B' R' U L2
optimal crosses for orientation z
z F' D L F' D2 L'
z D F' L F' D2 L'
z D L F' L D2 L2
z D' F' L F' D2 F2
z F' D' L F' D2 F
z L D F' L D2 L'
z L' D B R2 F R'
z D' L F' L D2 F
z L D' F' L D2 F
z F D' R' B2 L' B
optimal crosses for orientation z'
z' R2 F D' B F2 D2
z' L2 R D B R F'
z' L2 R D B F' R
z' L2 R2 F D B F2
z' D2 B' D B2 F' D2
z' L2 D B U R2 F'
z' L2 D B U F' R2
z' L2 D B F' U R2
z' D' B U' L2 D2 B
z' D' B U' F' L2 D2
z' D' B U F' D2 R2
z' R D' B F' D2 R'
z' L2 D2 B' D' B2 F'
z' D2 L2 B' D' B2 F'
z' D' B F' U' L2 D2
z' D' B F' D' B2 D'
z' D' B F' D2 U R2
 
Last edited:

N's-cvt

Member
Joined
Feb 5, 2020
Messages
119
Nice video, I will probably need it for later when I get python on my computer.
Can you also make a video on how to use the grep command for move limits?
 

kubesolver

Premium Member
Joined
Nov 15, 2019
Messages
425
Here is "Unix utilities lesson 101" ;)

In general there is a bunch of unix-tool command line utilities that are super helpful to work with text files. Many of them have very simple functionality:
cat - a utility to print file contents
wc - a simple utility to count lines or words in text file
grep - positive and negative search for patterns
sed - find and replace
awk - more complex can do what sed and grep can do but requires some programming


most of these tools you can also download for windows either as standalone .exe files or in bundles (e.g. git for windows contain ports of most simple text-processing unix utils.

In particular grep's most typical usecase is to show only the lines containing particular sequence. To the point that in IT the verb to "grep" something means to find all occurences of particular pattern even with other tool than grep similarly like "to google" does not necessary mean to use google search engine to find it.

anyway - here is an example:

Code:
> kube_solver.exe -da 4 < in.txt > out.txt 
-- now we have some sequences generated to out.txt file

> wc -l out.txt
303 out.txt
-- wc told us that there 303 lines in the file.

-- now let's grep for sledgehammer
> grep "R' F R F'" out.txt
U' R' F R F' R' U' F' U F R
F2 U' F U' F' U2 F2 U' R' F R F'
F' U2 F R' F R F' U F R' F' R
U' R' F R F' R' U' F' U F R U2
F2 U' F U' F' U2 F2 U' R' F R F' U2
F' U2 F R' F R F' U F R' F' R U2
U' R' F R F' U F' U' L' U L F U'
U' R' F R F' U F' U' L' U L F U

--cool things about command-line utils is that we can combine them:
> grep "R' F R F'" out.txt | wc -l
8
-- there are 8 lines in the result above

> grep "R' F R F'" out.txt | wc
      8      99     264
8 lines, 99 words, 264 characters

>  grep -v "R' F R F'" out.txt | wc -l
295
-- grep has some options you can google and one of them is the negative pattern search with flag -v. So not surprisingly when we select sledgehammer as a negative pattern it will find 303 - 8 = 295 lines.

--and here a more complex example combining many tools in a pipeline. Notice that the output from kubesolver is not redirected to a file, but instead it's being fed directly to grep, and grep output is forwarded to sed which replaces sledge with a word SLEDGE
>./kubesolver.out < in.txt | grep "R' F R" | sed -e "s/R' F R F'/SLEDGE/g" 
U' SLEDGE R' U' F' U F R                                                                                
F2 U' F U' F' U2 F2 U' SLEDGE                                                                           
F' U2 F SLEDGE U F R' F' R                                                                              
U' SLEDGE R' U' F' U F R U2                                                                             
U' R' F R F2 L' U L F R U' R'                                                                           
F' L F R' F R F2 L' F U R U2 R'                                                                         
F' R U2 F U F' U2 R' U' R' F R U'                                                                       
F' R U2 F U F' U2 R' U' R' F R U                                                                        
F' U F R' F R F2 L F' L' F U F                                                                          
F2 U' F U' F' U2 F2 U' SLEDGE U2                                                                        
F' U2 F SLEDGE U F R' F' R U2                                                                           
U' SLEDGE U F' U' L' U L F U'                                                                           
U' SLEDGE U F' U' L' U L F U                                                                            
R' F R F2 L F' L' F L' U L F U'                                                                         
R' F R F2 L F' L' F L' U L F U                                                                          
U' R' F R F2 L' U L U2 L' U' L F                                                                        
U' R' F R F2 L' U L F R U' R' U2                                                                        
R' F R F2 R U' L' U R' U L F U'                                                                         
R' F R F2 R U' L' U R' U L F U
 

kubesolver

Premium Member
Joined
Nov 15, 2019
Messages
425
I have added a link to github repo in the first post.

I would like to share another example of how a command-line interface gives some extra flexibility that a GUI solver with fixed-features cannot.

In the github project I have added tools that show how to use engine to do some custom things.
For now there are python scripts to find a cross on an arbitrary scramble.

Another tool is called "generate_training_scrambles.py" and is a tool I use myself during training sessions as it gives a little extra over cs-timer training features. CStimer has plenty of nice features like last-slot, OLL only with a set of particular OLL, but what I wanted was a little different.

I wanted to train few particular OLLS, but I wanted the scramble to start with some simple insert so that I can train transition from F2L -> OLL, and additionally I wanted to force a PLL skip.

The way I can do it with kubesolver is to write a simple program to generate solutions I want to execute (generating random simple LS insert, then random AUF, then random OLL from the ones I want to pratcice) and generate a scramble for that.

for example let's say I want a R U R' or R U' R insert into sune/antisune into PLL skip or JPerm. I would write a program like that:

Code:
from util.solver import Solver
from util.scramble_util import fix_sequence
import random

pll = [
    "(R U R' F') (R U R' U') R' F R2 U' R'", # I can remove this like if I want to force a skip
    "",
    ]
oll = [
    "R U R' U R U2 R'",
    "R' U' R U' R' U2 R",
    ]
last_slot = [
    "R U R'",
    "R U' R'",
]

auf = [" ", " U ", " U2 ",  " U' "]

setup_groups = [
    auf,
    last_slot,
    auf,
    oll,
    auf,
    pll,
    auf
]

while True:
    setup = " ".join([fix_sequence(random.choice(g)) for g in setup_groups])
    with Solver("kube_solver.exe") as s:
        s.write_line("set n 1")
        s.write_line("set_gen RUFB")
        s.write_line(setup)
        s.write_line("solve")
        s.end_of_input()
        with open("OLL_drill_exercise.txt", "a") as myfile:
            for line in s.read_all_lines():
                line = line.strip()
                if line and not line.startswith("INFO"):
                        myfile.write(line)
                        myfile.write(" ")
                        print(line)
            myfile.write("\n")
        print()

The program will generate sequences into a file OLL_drill_exercise.txt and after I have enough of them I can input them as my input to cstimer session for practice.

B' F R' F' R B U' R2 B' R' B2 U' B' R'
R U2 R2 U' R F' R' F U F' R F
R U2 R' U' R U2 R' U
U B' U2 B U B' U B R U R'
U2 B' U2 B U B' U B R U' R' U
U2 F R U R' F R' F' R U' R' F' R
U R F2 U' R U' F2 U F2 R' U F2 U' R'
U2 R U' F' U' F U' F' U2 F R'
F' U2 F U F' U F R U R' U2
U' B' U2 B U B' U B R U R'
U' R U2 R2 U' F U F' R F U' F'
U' B U2 B' U' B U' B' R U' R' U2
U2 R U R2 U' R U' R' U2 R
F' U' F2 R B' R B R2 F2 U F U
U2 R' U' R U2 B U' F' U2 B' R' U2 R U F
F U2 F' U' F U' F' R U' R' U
B' R2 U R2 U' R2 U' R2 B R' U' R2 U R
R U2 R' B R2 U2 R' U' R U' R' U' R' B'
U' B U2 B' U' B U' B' R U' R' U2
B' U2 B U B' U B U' R U R' U
R B U' B' U' F R2 U' R2 U R2 U F' R'
F' U' F2 R B' R B R2 F2 U F U
R' B' R U' R' B R2 U' B' U2 B U' R'
U B F U2 F' U' F U2 B' U F' R U2 R' U2
U2 R' U2 R U R' U R2 U' R' U2
F' U B U' F U B' R U R'
F U R U' R F' U2 F' U' F2 R' F2 U' F R2
R U' F' U' F U' F' U2 F R' U2
R U B F' U2 B R2 B2 F R U2 B' F2 U2 B F2
R2 B2 R' B U R F' U F2 R F2 U' F R' B R'
R2 U B' F' U' B U F U' R' U' B' U2 B R'
U2 R U2 R' U' R U2 R'
U2 B U2 B' U' B U' B' R U R' U
U2 R F2 U' R U' F2 U F2 R' U F2 U' R'
F' U2 F U F' U F U R U R' U2
F U' B' U F' R U' R' U' B R U' R' U
F R' F' R B U' B2 F' U F U' B2 U B'
U' R U2 B R' F' R B' R' F U' R U R'
B' U2 B U B' U B U2 R U R' U
U R' U2 R U R' U R2 U R' U
 

kubesolver

Premium Member
Joined
Nov 15, 2019
Messages
425
there is no way at the moment - how important is this?

it's relatively easy to sort the output sequences by qtm so I'm not sure if I want to implement it.
 

N's-cvt

Member
Joined
Feb 5, 2020
Messages
119
Personally it is really important, I'm not sure about the rest of the users but I'm positive they would use it, I think it would be a fun and a nice feature to implement, just a simple add_qtm would be cool.
 

kubesolver

Premium Member
Joined
Nov 15, 2019
Messages
425
Ok, I will add it. It's not a super-trivial change however. There are some shortcuts in my code that assume htm. In particular the way I forbid sequences of cancelling moves like R R2, R L R etc.
I will have to rethink the design of this part of a program.
 

N's-cvt

Member
Joined
Feb 5, 2020
Messages
119
So after learning some more grep I have learned how to exclude moves like F2, but how would I code it to say I want the algs with only 1 F and 1 F'? I could use perl or python and utilize regular expressions but I wanted to see if there was a simpler more intuitive way to do it?
 

kubesolver

Premium Member
Joined
Nov 15, 2019
Messages
425
grep uses regular expressions. so you can do it still with grep.
e6c7541e2398e3e357327a2f52144740.png

grep ^[^F]*F[^\'2][^F]*F\'[^F]*$ out.txt

This expression means:

^ - the beginning of the line
[^F]* - arbitrary number of characters which are not F
F[^\'2] - F followed by a character that is not an apostrophe nor a 2
[^F]* - arbitrary number of characters which are not F
F\' - F'
[^F]* - arbitrary number of characters which are not F
$ - the end of line
 
Top