diff options
Diffstat (limited to 'README.md')
| -rw-r--r-- | README.md | 73 |
1 files changed, 58 insertions, 15 deletions
| @@ -139,22 +139,61 @@ UL1 UB0 BL0 FR1 DF0 UR1 DB0 FL0 DR1 DL1 UF0 BR1 DFR2 DBR0 DFL2 UFR2 UBL2 UFL0 UB | |||
| 139 | To solve a cube you can use: | 139 | To solve a cube you can use: |
| 140 | 140 | ||
| 141 | ``` | 141 | ``` |
| 142 | $ ./run solve -solver "h48h0k4" -n 1 -M 4 -cube "JLQWSVUH=ZLCUABGIVTKH" | 142 | $ ./run solve -solver h48h0k4 -n 1 -M 4 -cube "JLQWSVUH=ZLCUABGIVTKH" |
| 143 | Found 0 solutions, searching at depth 0 | 143 | F' U' R |
| 144 | Found 0 solutions, searching at depth 1 | 144 | ``` |
| 145 | Found 0 solutions, searching at depth 2 | 145 | |
| 146 | Found 0 solutions, searching at depth 3 | 146 | Or alternatively: |
| 147 | Solution found: F' U R | 147 | |
| 148 | F' U R | 148 | ``` |
| 149 | $ ./run solve_scramble -solver h48h0k4 -n 1 -M 4 -moves "R' U' F" | ||
| 150 | F' U' R | ||
| 149 | ``` | 151 | ``` |
| 150 | 152 | ||
| 151 | For a full list of available command, use `run help`. | 153 | For a full list of available command, use `run help`. |
| 152 | 154 | ||
| 153 | ## Running commands from a Python shell | 155 | ## Using this software as a library |
| 156 | |||
| 157 | This tool has been developed as a library, so it can be easily included | ||
| 158 | in other programs. For this reason, some bindings for languages other | ||
| 159 | than C are available. | ||
| 160 | |||
| 161 | The API is documented in the public header file `src/nissy.h`. | ||
| 162 | |||
| 163 | ### C | ||
| 164 | |||
| 165 | To use this in a C project, simly include `src/nissy.h`. The tools | ||
| 166 | in the `tools/` folder are a good example for how to use this. | ||
| 167 | |||
| 168 | NOTE: this project is developed using the C11 standard. If you are using | ||
| 169 | an older version of C, you can write your own header file. | ||
| 170 | |||
| 171 | ### C++ | ||
| 172 | |||
| 173 | The `cpp` folder contains a C++ header `nissy.h` (C++20 standard) and an | ||
| 174 | implementation file `nissy.cpp`. This interface wraps the calls to the | ||
| 175 | C functions in an object-oriented C++ interface for more convenient use. | ||
| 154 | 176 | ||
| 155 | There is a work-in-progress python module available. To build it you need | 177 | The `cpp/examples` folder contains some examples for how to use this |
| 156 | the Python development headers installed. You can check this from the output | 178 | interface. You can build them with e.g. |
| 157 | of `./configure.sh`: | 179 | |
| 180 | ``` | ||
| 181 | g++ -std=c++20 cpp/nissy.cpp cpp/examples/solve_h48h3k2.cpp nissy.o | ||
| 182 | ``` | ||
| 183 | |||
| 184 | NOTE: If you prefer to use a C-style API, you'll have to write | ||
| 185 | your own header, similar to the `extern "C" {}` block at the top of | ||
| 186 | `cpp/nissy.cpp`. The C header `src/nissy.h` cannot be compiled as C++, | ||
| 187 | as it uses features of C that are not compatible with it. | ||
| 188 | |||
| 189 | ### Python | ||
| 190 | |||
| 191 | The `python` folder contains a Python module. The API provided by | ||
| 192 | this module follows the C API quite closely, except its functions | ||
| 193 | sometimes return strings instead of writing to `char *` buffers. | ||
| 194 | |||
| 195 | To build the Python module you need the Python development headers | ||
| 196 | installed. You can check this from the output of `./configure.sh`: | ||
| 158 | 197 | ||
| 159 | ``` | 198 | ``` |
| 160 | $ ./configure.sh | 199 | $ ./configure.sh |
| @@ -182,14 +221,18 @@ From here you can call the library functions directly, for example: | |||
| 182 | 'ASTUGFBH=DACXEZGBLIKF' | 221 | 'ASTUGFBH=DACXEZGBLIKF' |
| 183 | ``` | 222 | ``` |
| 184 | 223 | ||
| 185 | Some methods have a different signature in the Pythn module than in | 224 | The `python/examples` folder contains some examples, that you |
| 186 | libnissy: for example `solve()` returns the solutions as a list of | 225 | can run for example with: |
| 187 | strings instead of writing them to a return parameter buffer. | 226 | |
| 227 | ``` | ||
| 228 | $ python python/examples/solve.py | ||
| 229 | ``` | ||
| 230 | |||
| 188 | You can access the documentation for the Python module from within | 231 | You can access the documentation for the Python module from within |
| 189 | a Python interpreter with `help(nissy)`. Cross-check this documentation | 232 | a Python interpreter with `help(nissy)`. Cross-check this documentation |
| 190 | with the comments in nissy.h for more details. | 233 | with the comments in nissy.h for more details. |
| 191 | 234 | ||
| 192 | Please note: the support for the Python module is still rudimentary. | 235 | NOTE: Support for the Python module is still rudimentary. |
| 193 | 236 | ||
| 194 | ## Cube formats | 237 | ## Cube formats |
| 195 | 238 | ||
