Skip to content

Odder/PyraminXolver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PyraminXolver

A pyraminx solver!

Installation

Download using pip

pip  install pyraminxolver

Setup the pyraminx graph (this should take around 5-30 seconds). You only need to run this once.

pyraminxolver-setup

Usage

Command-line interface

You can either supply a scramble like this:

pyraminxolver --scramble="R U R' L' U R"

or in input file with scrambles

pyraminxolver --input-file=scrambles.txt

where the content of scrambles.txt looks like this

L U R L U' B' R
L R U R L R U R

If you also want it to find suboptimal solutions you can use the slack to indicate how many moves from optimal you will allow the solutions to be.

pyraminxolver --scramble="R U R' L' U R" --slack=2

Programmatical interface

from pyraminxolver import PyraminXolver

px = PyraminXolver()
solutions = px.search_scramble("R U L R U L B' R' U")
for solution, move_count, time_ns, _ in solutions:
    print(f'{solution} ({move_count} moves found in {time_ns // 1000000}ms)')

Generating algs for L4E with 2 moves slack for each case and dumping them into a file.

from pyraminxolver import PyraminXolver, Pyraminx

slack = 2
file_name = 'l4e-solutions.txt'
pyra = PyraminXolver()
cases = Pyraminx.set([
    [-1, -1, -1, 0, -1, 0],
    [0, 0, 0, 0],
    [-1, -1, -1, 3, -1, 5],
])

for case in cases:
    solutions = pyra.search(case, slack)
    with open(file_name, 'a') as f:
        f.write(f'\nSolving a new L4E case\n')
        for solution, length, timing, _ in solutions:
            f.write(f'{solution} ({length})\n')

State explanation:

When generating a set we need to describe the properties of the pyraminx. We describe a fixed position, with some "wildcards" and then all valid cases will be based off that. The first array descibes EO, then CO and lastly EP.

[
    [UB, UR, UL, BR, RL, BL], # EO
    [U, R, L, B], # CO
    [UB, UR, UL, BR, RL, BL] # EP
]

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages