diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2023-10-22 23:34:53 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2023-10-22 23:43:36 +0200 |
| commit | b3622e04dfb8317b745f8c911d31dc80bc2f9d66 (patch) | |
| tree | 825e54d062667a6cb76ff36730a8e36444fa20ba /src/cube.c | |
| parent | 4a7e2dccaa54bc42a4b67cf35cf8b926cf357bb3 (diff) | |
| download | nissy-core-b3622e04dfb8317b745f8c911d31dc80bc2f9d66.tar.gz nissy-core-b3622e04dfb8317b745f8c911d31dc80bc2f9d66.zip | |
Preparatory work for benchmarks, little fixes
Diffstat (limited to '')
| -rw-r--r-- | src/cube.c | 67 |
1 files changed, 28 insertions, 39 deletions
| @@ -605,8 +605,10 @@ issolvable(cube_t cube) | |||
| 605 | int8_t i, eo, co; | 605 | int8_t i, eo, co; |
| 606 | 606 | ||
| 607 | #ifdef DEBUG | 607 | #ifdef DEBUG |
| 608 | if (!isconsistent(cube)) | 608 | if (!isconsistent(cube)) { |
| 609 | goto issolvable_inconsistent; | 609 | fprintf(stderr, "issolvable: cube is inconsistent\n"); |
| 610 | return false; | ||
| 611 | } | ||
| 610 | #endif | 612 | #endif |
| 611 | 613 | ||
| 612 | if (permsign(cube.e, 12) != permsign(cube.c, 8)) | 614 | if (permsign(cube.e, 12) != permsign(cube.c, 8)) |
| @@ -626,11 +628,6 @@ issolvable(cube_t cube) | |||
| 626 | 628 | ||
| 627 | return true; | 629 | return true; |
| 628 | 630 | ||
| 629 | issolvable_inconsistent: | ||
| 630 | #ifdef DEBUG | ||
| 631 | fprintf(stderr, "issolvable: cube is inconsistent\n"); | ||
| 632 | #endif | ||
| 633 | return false; | ||
| 634 | issolvable_parity: | 631 | issolvable_parity: |
| 635 | #ifdef DEBUG | 632 | #ifdef DEBUG |
| 636 | fprintf(stderr, "EP and CP parities are different\n"); | 633 | fprintf(stderr, "EP and CP parities are different\n"); |
| @@ -683,8 +680,10 @@ move(cube_t c, move_t m) | |||
| 683 | uint8_t aux, auy, auz; | 680 | uint8_t aux, auy, auz; |
| 684 | 681 | ||
| 685 | #ifdef DEBUG | 682 | #ifdef DEBUG |
| 686 | if (!isconsistent(c)) | 683 | if (!isconsistent(c)) { |
| 687 | goto move_inconsistent; | 684 | fprintf(stderr, "move error, inconsistent cube\n"); |
| 685 | goto move_error; | ||
| 686 | } | ||
| 688 | #endif | 687 | #endif |
| 689 | 688 | ||
| 690 | #define PERM4(r, i, j, k, l) \ | 689 | #define PERM4(r, i, j, k, l) \ |
| @@ -830,15 +829,12 @@ move(cube_t c, move_t m) | |||
| 830 | 829 | ||
| 831 | return ret; | 830 | return ret; |
| 832 | default: | 831 | default: |
| 833 | goto move_unknown; | 832 | #ifdef DEBUG |
| 833 | fprintf(stderr, "mover error, unknown move\n"); | ||
| 834 | #endif | ||
| 835 | goto move_error; | ||
| 834 | } | 836 | } |
| 835 | 837 | ||
| 836 | move_inconsistent: | ||
| 837 | fprintf(stderr, "move error, inconsistent cube\n"); | ||
| 838 | goto move_error; | ||
| 839 | move_unknown: | ||
| 840 | fprintf(stderr, "mover error, unknown move\n"); | ||
| 841 | goto move_error; | ||
| 842 | move_error: | 838 | move_error: |
| 843 | return errorcube; | 839 | return errorcube; |
| 844 | } | 840 | } |
| @@ -850,8 +846,10 @@ inverse(cube_t c) | |||
| 850 | cube_t ret = {0}; | 846 | cube_t ret = {0}; |
| 851 | 847 | ||
| 852 | #ifdef DEBUG | 848 | #ifdef DEBUG |
| 853 | if (!isconsistent(c)) | 849 | if (!isconsistent(c)) { |
| 854 | goto inverse_inconsistent; | 850 | fprintf(stderr, "inverse error, inconsistent cube\n"); |
| 851 | return errorcube; | ||
| 852 | } | ||
| 855 | #endif | 853 | #endif |
| 856 | 854 | ||
| 857 | for (i = 0; i < 12; i++) { | 855 | for (i = 0; i < 12; i++) { |
| @@ -867,10 +865,6 @@ inverse(cube_t c) | |||
| 867 | } | 865 | } |
| 868 | 866 | ||
| 869 | return ret; | 867 | return ret; |
| 870 | |||
| 871 | inverse_inconsistent: | ||
| 872 | fprintf(stderr, "inverse error, inconsistent cube\n"); | ||
| 873 | return errorcube; | ||
| 874 | } | 868 | } |
| 875 | 869 | ||
| 876 | cube_t | 870 | cube_t |
| @@ -880,8 +874,10 @@ compose(cube_t c1, cube_t c2) | |||
| 880 | cube_t ret = {0}; | 874 | cube_t ret = {0}; |
| 881 | 875 | ||
| 882 | #ifdef DEBUG | 876 | #ifdef DEBUG |
| 883 | if (!isconsistent(c1) || !isconsistent(c2)) | 877 | if (!isconsistent(c1) || !isconsistent(c2)) { |
| 884 | goto compose_inconsistent; | 878 | fprintf(stderr, "compose error, inconsistent cube\n"); |
| 879 | return errorcube; | ||
| 880 | } | ||
| 885 | #endif | 881 | #endif |
| 886 | 882 | ||
| 887 | for (i = 0; i < 12; i++) { | 883 | for (i = 0; i < 12; i++) { |
| @@ -899,10 +895,6 @@ compose(cube_t c1, cube_t c2) | |||
| 899 | } | 895 | } |
| 900 | 896 | ||
| 901 | return ret; | 897 | return ret; |
| 902 | |||
| 903 | compose_inconsistent: | ||
| 904 | fprintf(stderr, "compose error, inconsistent cube\n"); | ||
| 905 | return errorcube; | ||
| 906 | } | 898 | } |
| 907 | 899 | ||
| 908 | static cube_t | 900 | static cube_t |
| @@ -1122,10 +1114,14 @@ transform(cube_t c, trans_t t) | |||
| 1122 | cube_t ret; | 1114 | cube_t ret; |
| 1123 | 1115 | ||
| 1124 | #ifdef DEBUG | 1116 | #ifdef DEBUG |
| 1125 | if (!isconsistent(c)) | 1117 | if (!isconsistent(c)) { |
| 1126 | goto transform_inconsistent; | 1118 | fprintf(stderr, "transform error, inconsistent cube\n"); |
| 1127 | if (t >= 48) | 1119 | return errorcube; |
| 1128 | goto transform_errortrans; | 1120 | } |
| 1121 | if (t >= 48) { | ||
| 1122 | fprintf(stderr, "transform error, unknown transformation\n"); | ||
| 1123 | return errorcube; | ||
| 1124 | } | ||
| 1129 | #endif | 1125 | #endif |
| 1130 | 1126 | ||
| 1131 | ret = compose(solvedcube, trans_move_cube[t]); | 1127 | ret = compose(solvedcube, trans_move_cube[t]); |
| @@ -1138,11 +1134,4 @@ transform(cube_t c, trans_t t) | |||
| 1138 | ret = flipallcorners(ret); | 1134 | ret = flipallcorners(ret); |
| 1139 | 1135 | ||
| 1140 | return ret; | 1136 | return ret; |
| 1141 | |||
| 1142 | transform_inconsistent: | ||
| 1143 | fprintf(stderr, "transform error, inconsistent cube\n"); | ||
| 1144 | return errorcube; | ||
| 1145 | transform_errortrans: | ||
| 1146 | fprintf(stderr, "transform error, unknown transformation\n"); | ||
| 1147 | return errorcube; | ||
| 1148 | } | 1137 | } |
