cubecore

A library of core functions for working with 3x3x3 Rubik's cubes
git clone https://git.tronto.net/cubecore
Download | Log | Files | Refs | README | LICENSE

example.cpp (701B)


      1 #include <cinttypes>
      2 #include <iostream>
      3 #include <vector>
      4 
      5 extern "C" {
      6 #include "../cube.h"
      7 }
      8 
      9 cube_t apply_alg(cube_t cube, std::vector<move_t>& moves) {
     10 	auto ret {cube};
     11 
     12 	for (auto m : moves)
     13 		ret = cube_move(ret, m);
     14 
     15 	return ret;
     16 }
     17 
     18 int main() {
     19 	auto cube {cube_new()};
     20 	std::vector<move_t> moves { R, U, R3, U3 };
     21 	char cstr[500];
     22 
     23 	std::cout << "The solved cube looks like this in H48 notation:\n";
     24 	cube_write("H48", cube, cstr);
     25 	std::string solvedstr(cstr);
     26 	std::cout << solvedstr << "\n";
     27 	std::cout << "After a sexy move it looks like this:\n";
     28 	cube = apply_alg(cube, moves);
     29 	cube_write("H48", cube, cstr);
     30 	std::string sexystr(cstr);
     31 	std::cout << sexystr << "\n";
     32 	
     33 	return 0;
     34 }