diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2022-06-01 11:41:18 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2022-06-01 11:41:18 +0200 |
| commit | ff742b8922a0a179135dc35ea66c231d5c22b1bf (patch) | |
| tree | fbbfecfa1eae70876e6b3ad36c9faae9e2cf44d8 | |
| parent | c913d8b3563d0fbcda603ac4cdae8dcbb734055f (diff) | |
| download | nissy-ff742b8922a0a179135dc35ea66c231d5c22b1bf.tar.gz nissy-ff742b8922a0a179135dc35ea66c231d5c22b1bf.zip | |
Save more stuff to file
| -rw-r--r-- | TODO.md | 2 | ||||
| -rwxr-xr-x | nissy | bin | 327920 -> 327920 bytes | |||
| -rw-r--r-- | src/shell.c | 1 | ||||
| -rw-r--r-- | src/symcoord.c | 147 |
4 files changed, 133 insertions, 17 deletions
| @@ -5,7 +5,7 @@ It's more of a personal reminder than anything else. | |||
| 5 | 5 | ||
| 6 | ## For version 2.1 | 6 | ## For version 2.1 |
| 7 | ### Moving coordinates | 7 | ### Moving coordinates |
| 8 | * memorize some tables from symcoord in files | 8 | * parallelize genptable_fixnasty |
| 9 | * general cleanup | 9 | * general cleanup |
| 10 | ### Changes to Step and Solve | 10 | ### Changes to Step and Solve |
| 11 | * add a list of "helper" coordinates to every step | 11 | * add a list of "helper" coordinates to every step |
| Binary files differ | |||
diff --git a/src/shell.c b/src/shell.c index 30d02be..77d5d1d 100644 --- a/src/shell.c +++ b/src/shell.c | |||
| @@ -143,7 +143,6 @@ main(int argc, char *argv[]) | |||
| 143 | char *closing_cmd[1] = { "freemem" }; | 143 | char *closing_cmd[1] = { "freemem" }; |
| 144 | 144 | ||
| 145 | init_env(); | 145 | init_env(); |
| 146 | /*print_ptable(&pd_nxopt31_HTM);*/ | ||
| 147 | 146 | ||
| 148 | if (!checkfiles()) { | 147 | if (!checkfiles()) { |
| 149 | fprintf(stderr, | 148 | fprintf(stderr, |
diff --git a/src/symcoord.c b/src/symcoord.c index 5c6634e..c852ef2 100644 --- a/src/symcoord.c +++ b/src/symcoord.c | |||
| @@ -31,7 +31,11 @@ static void gensym(SymData *sd); | |||
| 31 | static void init_symc_moves(); | 31 | static void init_symc_moves(); |
| 32 | static void init_symc_trans(); | 32 | static void init_symc_trans(); |
| 33 | static bool read_symdata_file(SymData *sd); | 33 | static bool read_symdata_file(SymData *sd); |
| 34 | static bool read_symc_moves_file(); | ||
| 35 | static bool read_symc_trans_file(); | ||
| 34 | static bool write_symdata_file(SymData *sd); | 36 | static bool write_symdata_file(SymData *sd); |
| 37 | static bool write_symc_moves_file(); | ||
| 38 | static bool write_symc_trans_file(); | ||
| 35 | 39 | ||
| 36 | /* Some tables ***************************************************************/ | 40 | /* Some tables ***************************************************************/ |
| 37 | 41 | ||
| @@ -420,26 +424,66 @@ read_symdata_file(SymData *sd) | |||
| 420 | return r; | 424 | return r; |
| 421 | } | 425 | } |
| 422 | 426 | ||
| 423 | /* | 427 | static bool |
| 424 | static int | 428 | read_symc_moves_file() |
| 425 | selfsims(SymData *sd, uint64_t ind, Trans *ret) | ||
| 426 | { | 429 | { |
| 427 | Cube cube, tcube; | 430 | init_env(); |
| 428 | int i, n; | ||
| 429 | uint64_t indnosym; | ||
| 430 | 431 | ||
| 431 | cube = sd->sym_coord->cube(ind); | 432 | Move m; |
| 432 | indnosym = sd->coord->index(cube); | 433 | bool r = true; |
| 433 | n = 0; | 434 | FILE *f; |
| 434 | for (i = 0; i < sd->ntrans; i++) { | 435 | char fname[strlen(tabledir)+100]; |
| 435 | tcube = apply_trans(sd->trans[i], cube); | 436 | |
| 436 | if (sd->coord->index(tcube) == indnosym) | 437 | strcpy(fname, tabledir); |
| 437 | ret[n++] = sd->trans[i]; | 438 | strcat(fname, "/symc_moves"); |
| 439 | |||
| 440 | if ((f = fopen(fname, "rb")) == NULL) | ||
| 441 | return false; | ||
| 442 | |||
| 443 | for (m = 0; m < NMOVES; m++) { | ||
| 444 | r = r && fread(move_cp_16[m], sizeof(uint64_t), | ||
| 445 | CLASSES_CP_16, f) == CLASSES_CP_16; | ||
| 446 | r = r && fread(move_eofbepos_16[m], sizeof(uint64_t), | ||
| 447 | CLASSES_EOFBEPOS_16, f) == CLASSES_EOFBEPOS_16; | ||
| 448 | |||
| 449 | r = r && fread(ttrep_move_cp_16[m], sizeof(Trans), | ||
| 450 | CLASSES_CP_16, f) == CLASSES_CP_16; | ||
| 451 | r = r && fread(ttrep_move_eofbepos_16[m], sizeof(Trans), | ||
| 452 | CLASSES_EOFBEPOS_16, f) == CLASSES_EOFBEPOS_16; | ||
| 438 | } | 453 | } |
| 439 | 454 | ||
| 440 | return n; | 455 | fclose(f); |
| 456 | return r; | ||
| 457 | } | ||
| 458 | |||
| 459 | static bool | ||
| 460 | read_symc_trans_file() | ||
| 461 | { | ||
| 462 | init_env(); | ||
| 463 | |||
| 464 | Trans t; | ||
| 465 | bool r = true; | ||
| 466 | FILE *f; | ||
| 467 | char fname[strlen(tabledir)+100]; | ||
| 468 | |||
| 469 | strcpy(fname, tabledir); | ||
| 470 | strcat(fname, "/symc_trans"); | ||
| 471 | |||
| 472 | if ((f = fopen(fname, "rb")) == NULL) | ||
| 473 | return false; | ||
| 474 | |||
| 475 | for (t = 0; t < NTRANS; t++) { | ||
| 476 | r = r && fread(trans_eofbepos[t], sizeof(int), | ||
| 477 | POW2TO11*BINOM12ON4, f) == POW2TO11*BINOM12ON4; | ||
| 478 | r = r && fread(trans_epud[t], sizeof(int), | ||
| 479 | FACTORIAL8, f) == FACTORIAL8; | ||
| 480 | r = r && fread(trans_cpud_separate[t], sizeof(int), | ||
| 481 | BINOM8ON4, f) == BINOM8ON4; | ||
| 482 | } | ||
| 483 | |||
| 484 | fclose(f); | ||
| 485 | return r; | ||
| 441 | } | 486 | } |
| 442 | */ | ||
| 443 | 487 | ||
| 444 | static bool | 488 | static bool |
| 445 | write_symdata_file(SymData *sd) | 489 | write_symdata_file(SymData *sd) |
| @@ -468,12 +512,76 @@ write_symdata_file(SymData *sd) | |||
| 468 | return r; | 512 | return r; |
| 469 | } | 513 | } |
| 470 | 514 | ||
| 515 | static bool | ||
| 516 | write_symc_moves_file() | ||
| 517 | { | ||
| 518 | init_env(); | ||
| 519 | |||
| 520 | Move m; | ||
| 521 | bool r = true; | ||
| 522 | FILE *f; | ||
| 523 | char fname[strlen(tabledir)+100]; | ||
| 524 | |||
| 525 | strcpy(fname, tabledir); | ||
| 526 | strcat(fname, "/symc_moves"); | ||
| 527 | |||
| 528 | if ((f = fopen(fname, "wb")) == NULL) | ||
| 529 | return false; | ||
| 530 | |||
| 531 | for (m = 0; m < NMOVES; m++) { | ||
| 532 | r = r && fwrite(move_cp_16[m], sizeof(uint64_t), | ||
| 533 | CLASSES_CP_16, f) == CLASSES_CP_16; | ||
| 534 | r = r && fwrite(move_eofbepos_16[m], sizeof(uint64_t), | ||
| 535 | CLASSES_EOFBEPOS_16, f) == CLASSES_EOFBEPOS_16; | ||
| 536 | |||
| 537 | r = r && fwrite(ttrep_move_cp_16[m], sizeof(Trans), | ||
| 538 | CLASSES_CP_16, f) == CLASSES_CP_16; | ||
| 539 | r = r && fwrite(ttrep_move_eofbepos_16[m], sizeof(Trans), | ||
| 540 | CLASSES_EOFBEPOS_16, f) == CLASSES_EOFBEPOS_16; | ||
| 541 | } | ||
| 542 | |||
| 543 | fclose(f); | ||
| 544 | return r; | ||
| 545 | } | ||
| 546 | |||
| 547 | static bool | ||
| 548 | write_symc_trans_file() | ||
| 549 | { | ||
| 550 | init_env(); | ||
| 551 | |||
| 552 | Trans t; | ||
| 553 | bool r = true; | ||
| 554 | FILE *f; | ||
| 555 | char fname[strlen(tabledir)+100]; | ||
| 556 | |||
| 557 | strcpy(fname, tabledir); | ||
| 558 | strcat(fname, "/symc_trans"); | ||
| 559 | |||
| 560 | if ((f = fopen(fname, "wb")) == NULL) | ||
| 561 | return false; | ||
| 562 | |||
| 563 | for (t = 0; t < NTRANS; t++) { | ||
| 564 | r = r && fwrite(trans_eofbepos[t], sizeof(int), | ||
| 565 | POW2TO11*BINOM12ON4, f) == POW2TO11*BINOM12ON4; | ||
| 566 | r = r && fwrite(trans_epud[t], sizeof(int), | ||
| 567 | FACTORIAL8, f) == FACTORIAL8; | ||
| 568 | r = r && fwrite(trans_cpud_separate[t], sizeof(int), | ||
| 569 | BINOM8ON4, f) == BINOM8ON4; | ||
| 570 | } | ||
| 571 | |||
| 572 | fclose(f); | ||
| 573 | return r; | ||
| 574 | } | ||
| 575 | |||
| 471 | static void | 576 | static void |
| 472 | init_symc_moves() | 577 | init_symc_moves() |
| 473 | { | 578 | { |
| 474 | uint64_t i, ii, coo; | 579 | uint64_t i, ii, coo; |
| 475 | Move j; | 580 | Move j; |
| 476 | 581 | ||
| 582 | if (read_symc_moves_file()) | ||
| 583 | return; | ||
| 584 | |||
| 477 | for (i = 0; i < CLASSES_CP_16; i++) { | 585 | for (i = 0; i < CLASSES_CP_16; i++) { |
| 478 | ii = sd_cp_16.unsym[i]; | 586 | ii = sd_cp_16.unsym[i]; |
| 479 | for (j = 0; j < NMOVES; j++) { | 587 | for (j = 0; j < NMOVES; j++) { |
| @@ -492,6 +600,9 @@ init_symc_moves() | |||
| 492 | sd_eofbepos_16.transtorep[coo]; | 600 | sd_eofbepos_16.transtorep[coo]; |
| 493 | } | 601 | } |
| 494 | } | 602 | } |
| 603 | |||
| 604 | if (!write_symc_moves_file()) | ||
| 605 | fprintf(stderr, "Error writing SymMoves file\n"); | ||
| 495 | } | 606 | } |
| 496 | 607 | ||
| 497 | void | 608 | void |
| @@ -505,6 +616,9 @@ init_symc_trans() | |||
| 505 | CubeArray *arr, *aux; | 616 | CubeArray *arr, *aux; |
| 506 | Trans t; | 617 | Trans t; |
| 507 | 618 | ||
| 619 | if (read_symc_trans_file()) | ||
| 620 | return; | ||
| 621 | |||
| 508 | for (i = 0; i < POW2TO11*BINOM12ON4; i++) { | 622 | for (i = 0; i < POW2TO11*BINOM12ON4; i++) { |
| 509 | for (j = 0; j < 16; j++) { | 623 | for (j = 0; j < 16; j++) { |
| 510 | t = trans_group_udfix[j]; | 624 | t = trans_group_udfix[j]; |
| @@ -543,6 +657,9 @@ init_symc_trans() | |||
| 543 | cpud_separate_ind[cp_ttable[t][cp]]; | 657 | cpud_separate_ind[cp_ttable[t][cp]]; |
| 544 | } | 658 | } |
| 545 | } | 659 | } |
| 660 | |||
| 661 | if (!write_symc_trans_file()) | ||
| 662 | fprintf(stderr, "Error writing SymTrans file\n"); | ||
| 546 | } | 663 | } |
| 547 | 664 | ||
| 548 | void | 665 | void |
