aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2024-04-13 19:22:49 +0200
committerSebastiano Tronto <sebastiano@tronto.net>2024-04-13 19:22:49 +0200
commit59ecc0ee72a180692fcccab88db310d60021f2ab (patch)
tree0038b500b6af1bb5b5c95e5aed590ce33b13401b
parentec87f96ffec31c430b6058663ae831c1b3a29ff9 (diff)
downloadcubecore-59ecc0ee72a180692fcccab88db310d60021f2ab.tar.gz
cubecore-59ecc0ee72a180692fcccab88db310d60021f2ab.zip
Fixed howto, added example
-rw-r--r--README.md12
-rw-r--r--cube.obin22112 -> 23088 bytes
-rwxr-xr-xexample/a.outbin0 -> 49752 bytes
-rwxr-xr-xexample/compile.sh1
-rw-r--r--example/example.cpp34
-rw-r--r--example/example.obin0 -> 33856 bytes
6 files changed, 45 insertions, 2 deletions
diff --git a/README.md b/README.md
index 131c7ed..a1b260a 100644
--- a/README.md
+++ b/README.md
@@ -4,7 +4,7 @@ A simple set of basic routines for working with a 3x3x3 Rubik's Cube.
4 4
5## How to use CubeCore 5## How to use CubeCore
6 6
7(More details coming soon) 7See the example in `example/` for details.
8 8
90. Requirements: a C99 compiler (e.g. GCC) 90. Requirements: a C99 compiler (e.g. GCC)
10 10
@@ -15,12 +15,20 @@ $ make
15$ make test # optional 15$ make test # optional
16``` 16```
17 17
182. Include in your C or C++ project 182. Include in your C project
19 19
20``` 20```
21#include "cube.h" 21#include "cube.h"
22``` 22```
23 23
24or in your C++ project
25
26```
27extern "C" {
28#include "cube.h"
29}
30```
31
243. Compile including the `cube.o` file 323. Compile including the `cube.o` file
25 33
26``` 34```
diff --git a/cube.o b/cube.o
index 9f4fb3d..e61cb30 100644
--- a/cube.o
+++ b/cube.o
Binary files differ
diff --git a/example/a.out b/example/a.out
new file mode 100755
index 0000000..ef2babe
--- /dev/null
+++ b/example/a.out
Binary files differ
diff --git a/example/compile.sh b/example/compile.sh
new file mode 100755
index 0000000..4ce3bd2
--- /dev/null
+++ b/example/compile.sh
@@ -0,0 +1 @@
g++ example.cpp ../cube.o
diff --git a/example/example.cpp b/example/example.cpp
new file mode 100644
index 0000000..60c998f
--- /dev/null
+++ b/example/example.cpp
@@ -0,0 +1,34 @@
1#include <cinttypes>
2#include <iostream>
3#include <vector>
4
5extern "C" {
6#include "../cube.h"
7}
8
9cube_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
18int main() {
19 auto cube = cube_new();
20 auto moves = new std::vector<move_t> { 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((char *)"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((char *)"H48", cube, cstr);
30 std::string sexystr(cstr);
31 std::cout << sexystr << "\n";
32
33 return 0;
34}
diff --git a/example/example.o b/example/example.o
new file mode 100644
index 0000000..af95a15
--- /dev/null
+++ b/example/example.o
Binary files differ

Generated with cgit - Back to sebastiano.tronto.net