Skip to content

Repository files navigation

Cube

GitHub License GitHub Release Hackage Crates.io PyPI npm

An ultra-fast, cross-platform Rubik's Cube solver engine built with modern C++17, implementing Kociemba's Two-Phase Algorithm.

✨ Features

  • ⚡ High Performance: Fast and resource-efficient core implementation.
  • 🌐 Multi-Language: Native bindings for Python, Rust, Haskell, and WebAssembly/TypeScript.
  • 📦 Cross-Platform SDK: Ships C dynamic/static libraries, Swift module (Cube.framework), and interactive CLI (icube).
  • 🛠️ Standalone: Zero external third-party dependencies.

📦 Language Bindings

Language Directory & Guide Package
Python bindings/python cube-python
Rust bindings/rust cube-rust
Haskell bindings/haskell cube-hs
TypeScript bindings/wasm @coshz/jscube

🚀 Quick Start

1. Interactive CLI (icube)

# Launch interactive solver
icube

# Or solve directly via state string
icube solve "UUUUUUUUURRRRRRRRRFFFFFFFFFDDDDDDDDDLLLLLLLLLBBBBBBBBB"
Click to view CLI screenshot (shotsnap) shotsnap-1

2. SDK Usage

#include <cube/cube.h>
#include <stdio.h>
#include <string.h>

int main() 
{
  char buf[CUBE_BS], sol[CUBE_BS];

  // apply maneuver to give cube (here, CUBE_ID)
  facecube(buf, "U F U' L2 R L' D2 B", CUBE_ID);

  // solve from buf to CUBE_ID
  SolveResult sr = solve(sol, buf, CUBE_ID, 30, true);

  if(sr == SolveResultSuccess) {
    puts(sol);
    // verify the solution 
    char solved[CUBE_BS];
    facecube(solved, sol, buf);
    if(strcmp(solved, CUBE_ID) == 0) {
      puts("solution verified");
    } else {
      puts("wrong solution");
    }
  } else {
    fprintf(stderr, "%s\n", solve_result_to_string(sr));
  }
  return 0;
}

🛠️ Build & Install

Prerequisites

  • CMake 3.15+
  • C++17 compatible compiler (Clang, GCC, MSVC)
  • Ninja (Optional, recommended)

Instructions

# Configure & build core SDK
cmake -B build -G "Ninja" -DCMAKE_BUILD_TYPE=Release
cmake --build build --config Release

# Install C++ artifacts to system default path
cmake --build build --target install

📂 Repository Layout

.
├── amalg/            # amalgamated C++ source
├── asset             # project static resources
├── bindings/         # Language bindings
├── cli/              # Source code for `icube` command-line tool
├── cmake/            # templates or modules for cmake use
├── dev/              # Scripts to eases development
├── include/          # Public C++ SDK headers
├── src/              # Core Two-Phase Algorithm implementation
└── test/             # Testing

📄 License

MIT © coshz

🔗 References

  1. http://kociemba.org/cube.htm

About

Rubik's cube solver

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages