{"id":13514757,"url":"https://github.com/tk744/rubot","last_synced_at":"2025-03-31T03:31:21.446Z","repository":{"id":45283027,"uuid":"425066919","full_name":"tk744/rubot","owner":"tk744","description":"A blazing fast 3x3 Rubik's cube solver written in C.","archived":false,"fork":false,"pushed_at":"2025-02-08T03:14:48.000Z","size":3747,"stargazers_count":1,"open_issues_count":6,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-08T03:20:18.392Z","etag":null,"topics":["algorithm","microcontroller","robotics","rubiks-cube"],"latest_commit_sha":null,"homepage":"","language":"C","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/tk744.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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":"2021-11-05T19:47:01.000Z","updated_at":"2025-02-08T02:31:00.000Z","dependencies_parsed_at":"2025-02-08T03:19:56.157Z","dependency_job_id":"585efa45-fb14-492b-a4f4-fdafb4cfc219","html_url":"https://github.com/tk744/rubot","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tk744%2Frubot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tk744%2Frubot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tk744%2Frubot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tk744%2Frubot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tk744","download_url":"https://codeload.github.com/tk744/rubot/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246413377,"owners_count":20773053,"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":["algorithm","microcontroller","robotics","rubiks-cube"],"created_at":"2024-08-01T05:01:01.379Z","updated_at":"2025-03-31T03:31:21.441Z","avatar_url":"https://github.com/tk744.png","language":"C","readme":"# Overview\n\n`rubot` is a blazing fast and user friendly Rubik's cube solver written in C. It uses a highly compact 1MB lookup table to deliver instantations solutions with an average of 32 moves and a max of 46 moves.\n\nSince `rubot` was originally designed for use in embedded systems, it implements [Thistletwaite's algorithm](https://www.jaapsch.net/puzzles/thistle.htm) which uses much smaller lookup tables compared to algorithms that produce even fewer moves.\n\n# Installation\n\n### Linux\n\n- Install (default location is `/usr/bin`):\n    ```\n    git clone https://github.com/tk744/rubot\n    cd rubot\n    sudo make install\n    ```\n\n- Uninstall:\n\n    ```\n    sudo make uninstall\n    ```\n\n### Build from Source\n\nBuild the executable `rubot` from source by running `make`.\n\n# Usage\n\nFor a full list of commands, run `rubot -h`.\n\n## Encoding\n\nA scramble or solution is encoded as a **move sequence**:\n- A move sequence is a whitespace-separated list of moves described using [standard notation](https://ruwix.com/the-rubiks-cube/notation/). The six base moves are `U`, `L`, `F`, `R`, `B`, `D`, which can be suffixed by `i` and `2` for inverse and half-turns.\n\nA cube is serialized as a **color string**:\n- A color string has 54 chars, one for each tile. It is arranged linearly by face, with the tiles in each face arranged in row-major order, and the faces arranged U, L, F, R, B, D. Colors are represented by any set of 6 unique chars.\n\n\u003cp align=\"center\"\u003e\n    \u003cimg \n    src=\"cube-string.png\"\n    alt=\"color string representation of a cube\" \n    width=\"400\"\u003e\n    \u003cbr\u003e\n    \u003ci\u003eThe index of each tile in the color string representation of a cube.\u003c/i\u003e\n\u003c/p\u003e\n\n## Cube Solving\n\n`rubot` can take a scrambled cube and return a solution sequence in one of two ways:\n\n- From a color string.\n    ```\n    $ ./rubot PBBWWBRGGWRWPPRBBRGPPGGWYYPYWWGRPBRYRPGWBYBRRGGWYYBYYP\n    Di Fi R Li U R L F R2 U2 F L R2 D2 R2 F U2 F R2 B2 D2 B U2 R2 U2 F2 R2 U2 F2 U2 L2 B2 L2 U2\n    ```\n\n- From a scramble sequence.\n    \n    ```\n    $ ./rubot F L2 D F B L2 U2 R U2 F D2 Fi B U B\n    U R F2 B D U2 R2 Bi Ri U2 Li Fi R F D2 F2 D2 R2 F R2 B R2 U2 F2 L2 F2 L2 B2 U2 L2\n    ```\n\n`rubot` can also print the state of the scrambled cube using either the `-c` or `-d` flag:\n\n- `-c`: print the color string.\n    \n    ```\n    $ ./rubot -c D2 L B D B U2 Fi L B D U D Fi Di R\n    FBURURBFDUFRULBFUDDLFLFLBDDLDRURLFUUBRRDBFLBULFRRDBLDB\n    ```\n\n- `-d`: draw a colored ASCII representation (requires a terminal with ANSII escape codes).\n    \n    ```\n    $ ./rubot -d UDUDUDUDULRLRLRLRLFBFBFBFBFRLRLRLRLRBFBFBFBFBDUDUDUDUD\n    \u003ctry it in a terminal\u003e\n    ```\n\n## Cube Scrambling\n\n`rubot` also provides functionality for generating random scramble sequences:\n\n- Pass the number of moves to generate, optionally followed by an RNG seed.\n    \n    ```\n    $ ./rubot 25 5\n    D2 U Fi B D F Ui Fi Ui F2 D B Fi D2 U Ri Bi F R L2 B2 Di B Ui Bi\n    ```\n\n- As with cube solving, we can use the `-c` or `-d` flag to print the state of the scrambled cube.\n    \n    ```\n    $ ./rubot -c 1000\n    URBFULFDULLRULRLDBUBLFFBRBDFUDLRDRUDLDBFBFFUDURBLDBFRR\n    ```\n\n## Benchmarking\n\n`rubot` can even run a simple benchmark by solving a large number of cubes using the `-b` flag:\n\n- `-b N`: benchmark on `N` scrambled cubes (output from my i7-13700K).\n\n    ```\n    $ ./rubot -b 100000\n    Throughput: 4585.70 solves per second\n    Length: 32.19 moves per solve\n    ```\n\n## Input Validation\n\n`rubot` will print to stderr and return a non-zero value if the input is invalid or if the cube is unsolvable:\n\n- Return -1 on invalid inputs with a descriptive error message.\n    \n    ```\n    $ ./rubot UUUUUUUUULLLxLLLLLFFFFFFFFFRRRRRRRRRBBBBBBBBBDDDDDDDDD\n    Error: Invalid color 'x' at index 12.\n    ```\n\n- Return 1 on unsolvable cubes, regardless of the operation.\n    \n    ```\n    $ ./rubot -d DUUUUUUUULLLLLLLLLFFFFFFFFFRRRRRRRRRBBBBBBBBBDDDDDDDDU\n    No solution found.\n    ```\n\n\u003c!-- \n# References\n\n1. [Thistlethwaite's 52-move Algorithm](https://www.jaapsch.net/puzzles/thistle.htm)\n\n1. https://www.stefan-pochmann.info/spocc/other_stuff/tools/solver_thistlethwaite/solver_thistlethwaite_cpp.txt\n\n1. https://www.stefan-pochmann.info/spocc/other_stuff/tools/solver_thistlethwaite/solver_thistlethwaite.txt\n\n1. [Implementing an Optimal Rubik’s Cube Solver using Korf’s Algorithm](https://medium.com/@benjamin.botto/implementing-an-optimal-rubiks-cube-solver-using-korf-s-algorithm-bf750b332cf9)\n\n1. [Sequentially Indexing Permutations: A Linear Algorithm for Computing Lexicographic Rank](https://medium.com/@benjamin.botto/sequentially-indexing-permutations-a-linear-algorithm-for-computing-lexicographic-rank-a22220ffd6e3)\n\n1. https://stackoverflow.com/a/3143594/14043949\n\n1. https://stackoverflow.com/a/66608800/14043949  --\u003e\n","funding_links":[],"categories":["C"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftk744%2Frubot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftk744%2Frubot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftk744%2Frubot/lists"}