diff options
| author | Sebastiano Tronto <sebastiano.tronto@gmail.com> | 2021-12-16 19:25:58 +0100 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano.tronto@gmail.com> | 2021-12-16 19:25:58 +0100 |
| commit | 2f924f942bd6e7126e8f1d8692e475c95bd9fe82 (patch) | |
| tree | dd5877c2fd836f43523263e48632946423401093 /src/moves.c | |
| parent | 4e2b4e603c7e84c7556f489d7d8dab06915b3a9b (diff) | |
| download | nissy-2f924f942bd6e7126e8f1d8692e475c95bd9fe82.tar.gz nissy-2f924f942bd6e7126e8f1d8692e475c95bd9fe82.zip | |
Added a new pruning table (equivalent to nxopt31). I have not tested it yet, it takes a while to generate.
Plus I have done a whole lot of refactoring in random places because I cannot focus on
one thing at the time.
Diffstat (limited to '')
| -rw-r--r-- | src/moves.c | 51 |
1 files changed, 0 insertions, 51 deletions
diff --git a/src/moves.c b/src/moves.c index 5aca0ee..9547de9 100644 --- a/src/moves.c +++ b/src/moves.c | |||
| @@ -319,57 +319,6 @@ write_mtables_file() | |||
| 319 | return r; | 319 | return r; |
| 320 | } | 320 | } |
| 321 | 321 | ||
| 322 | bool | ||
| 323 | commute(Move m1, Move m2) | ||
| 324 | { | ||
| 325 | static bool initialized = false; | ||
| 326 | static bool commute_aux[NMOVES][NMOVES]; | ||
| 327 | |||
| 328 | if (!initialized) { | ||
| 329 | Cube c1, c2; | ||
| 330 | int i, j; | ||
| 331 | |||
| 332 | for (i = 0; i < NMOVES; i++) { | ||
| 333 | for (j = 0; j < NMOVES; j++) { | ||
| 334 | c1 = apply_move(i, apply_move(j, (Cube){0})); | ||
| 335 | c2 = apply_move(j, apply_move(i, (Cube){0})); | ||
| 336 | commute_aux[i][j] = equal(c1, c2) && i && j; | ||
| 337 | } | ||
| 338 | } | ||
| 339 | |||
| 340 | initialized = true; | ||
| 341 | } | ||
| 342 | |||
| 343 | return commute_aux[m1][m2]; | ||
| 344 | } | ||
| 345 | |||
| 346 | bool | ||
| 347 | possible_next(Move m1, Move m2, Move m3) | ||
| 348 | { | ||
| 349 | static bool initialized = false; | ||
| 350 | static bool paux[NMOVES][NMOVES][NMOVES]; | ||
| 351 | |||
| 352 | if (!initialized) { | ||
| 353 | int i, j, k; | ||
| 354 | bool p, q, c; | ||
| 355 | |||
| 356 | for (i = 0; i < NMOVES; i++) { | ||
| 357 | for (j = 0; j < NMOVES; j++) { | ||
| 358 | for (k = 0; k < NMOVES; k++) { | ||
| 359 | p = j && base_move(j) == base_move(k); | ||
| 360 | q = i && base_move(i) == base_move(k); | ||
| 361 | c = commute(i, j); | ||
| 362 | paux[i][j][k] = !(p || (c && q)); | ||
| 363 | } | ||
| 364 | } | ||
| 365 | } | ||
| 366 | |||
| 367 | initialized = true; | ||
| 368 | } | ||
| 369 | |||
| 370 | return paux[m1][m2][m3]; | ||
| 371 | } | ||
| 372 | |||
| 373 | void | 322 | void |
| 374 | init_moves() { | 323 | init_moves() { |
| 375 | static bool initialized = false; | 324 | static bool initialized = false; |
