{"id":16138132,"url":"https://github.com/luckasranarison/kewb","last_synced_at":"2025-03-18T16:30:46.085Z","repository":{"id":160501773,"uuid":"635382774","full_name":"luckasRanarison/kewb","owner":"luckasRanarison","description":"Rubik's cube solver using Kociemba's two phase algorithm","archived":false,"fork":false,"pushed_at":"2024-05-15T03:45:24.000Z","size":111,"stargazers_count":5,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-15T06:35:42.630Z","etag":null,"topics":["cli","rubiks-cube-solver","two-phase-algorithm"],"latest_commit_sha":null,"homepage":"https://crates.io/crates/kewb","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/luckasRanarison.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-05-02T15:17:41.000Z","updated_at":"2024-09-27T13:55:51.000Z","dependencies_parsed_at":"2024-10-27T18:23:56.186Z","dependency_job_id":null,"html_url":"https://github.com/luckasRanarison/kewb","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luckasRanarison%2Fkewb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luckasRanarison%2Fkewb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luckasRanarison%2Fkewb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luckasRanarison%2Fkewb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/luckasRanarison","download_url":"https://codeload.github.com/luckasRanarison/kewb/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243940088,"owners_count":20372045,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","rubiks-cube-solver","two-phase-algorithm"],"created_at":"2024-10-09T23:32:16.913Z","updated_at":"2025-03-18T16:30:45.319Z","avatar_url":"https://github.com/luckasRanarison.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Kewb\n\n[![Build/test](https://github.com/luckasRanarison/kewb/actions/workflows/rust.yml/badge.svg)](https://github.com/luckasRanarison/kewb/actions/workflows/rust.yml)\n[![crates.io](https://img.shields.io/crates/v/kewb)](https://crates.io/crates/kewb)\n\nKewb is a library for manipulating and solving the 3x3 Rubiks's cube using Kociemba's [two-phase algorithm](http://kociemba.org/cube.htm). There is also a [CLI](#cli) version which showcases most of kewb features.\n\nPlease note that this is still a work in progress and the implementation is not yet efficient. The solver does not currently use symmetric reductions, pre-moves, or multi-threaded search.\n\n## Usage\n\n### Library\n\nSee https://docs.rs/kewb/latest/kewb/ for an exhaustive list of APIs provided by kewb.\n\nThe solver needs some precomputed data which is represented by the `DataTable` struct. However, generating it takes some amount of time so it's recommended to write it on the disk or bundle it with the executable. You can use the `write_table()` function or the `table` command from `kewb-cli` to generate the table.\n\n```rust\nuse kewb::{\n    error::Error,\n    generators::generate_state_cross_solved,\n    scramble::{scramble_from_state, scramble_from_str},\n    CubieCube, DataTable, FaceCube, Solver,\n};\n\nfn main() -\u003e Result\u003c(), Error\u003e {\n    // Method 1: Bundling the table in the executable\n    // const TABLE_BYTES = include_bytes!(\"./path_to_file\")\n    // let table = decode_table(\u0026TABLE_BYTES)?;\n\n    // Method 2: Reading the table from a file\n    // let table = read_table(\"./path_to_file\")?;\n\n    // Method 3: Generating the table at runtime (slow)\n    let table = DataTable::default();\n\n    let mut solver = Solver::new(\u0026table, 23, None);\n    let scramble = scramble_from_str(\"R U R' U'\")?; // vec![R, U, R3, U3]\n    let state = CubieCube::from(\u0026scramble);\n    let solution = solver.solve(state).unwrap();\n\n    println!(\"{}\", solution);\n\n    solver.clear();\n\n    let faces = \"DRBLUURLDRBLRRBFLFFUBFFDRUDURRBDFBBULDUDLUDLBUFFDBFLRL\";\n    let face_cube = FaceCube::try_from(faces)?;\n    let state = CubieCube::try_from(\u0026face_cube)?;\n    let solution = solver.solve(state).unwrap();\n\n    println!(\"{}\", solution);\n\n    solver.clear();\n\n    let cross_solved = generate_state_cross_solved();\n    let scramble = scramble_from_state(edges_solved, \u0026mut solver)?;\n\n    println!(\"{:?}\", scramble);\n\n    Ok(())\n}\n```\n\n### CLI\n\nBy default, there is no timeout, which means the solver will return the first solution it finds. However, by adding a timeout, the solver will continue searching until the timeout has elapsed and return the shortest solution found or nothing. Specifying a lower search depth can result in better solution quality (around 21 to 23 moves), but it can also make the search slower if the depth is less than 20 moves. Nevertheless, it has been proven that all cases can be solved in [20 moves or fewer](https://www.cube20.org/).\n\n```bash\nkewb-cli help\n# default values: max = 23, timeout = none, details = false\nkewb-cli solve --scramble \"R U R' U'\" --max 22 --timeout 1 --details\nkewb-cli solve -s \"R U R' U'\" -m 22 -t 1 -d\nkewb-cli solve --facelet DRBLUURLDRBLRRBFLFFUBFFDRUDURRBDFBBULDUDLUDLBUFFDBFLRL\n# default values: state = random, number = 1, preview = false\nkewb-cli scramble -p\nkewb-cli scramble -n 5\nkewb-cli scramble f2l-solved\n# generates the table used by the solver\nkewb-cli table ./path_to_file\n```\n\n## Build\n\n**NB: You must have the rust toolchain installed**\n\nClone the repository and run:\n\n```bash\ncargo build --release # build in target/build/\n# or\ncargo install --path ./kewb-cli # install to ~/.cargo/bin/\n```\n\n## Testing\n\nYou can run the tests by running:\n\n```bash\ncargo test --lib\n```\n\n## Todo\n\n- [x] Add Documentation\n- [ ] More CLI features\n- [ ] Algorithm optimization\n\n## References\n\n- Two phase algorithm overview: http://kociemba.org/cube.htm\n\n- Two phase algorithm implementation in python: https://qiita.com/7y2n/items/55abb991a45ade2afa28\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluckasranarison%2Fkewb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fluckasranarison%2Fkewb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluckasranarison%2Fkewb/lists"}