aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2024-04-22 19:23:45 +0200
committerSebastiano Tronto <sebastiano@tronto.net>2024-04-22 19:23:45 +0200
commitbdc7004014d3b62a72867bc78961feb7c4f73c2a (patch)
tree2e3c9bd3ea03f849b27e4998a6b4d9e8325fb8aa
parent9ed96a1ea3fc742791a8774267d5c7d5b604ce79 (diff)
downloadnissy-core-bdc7004014d3b62a72867bc78961feb7c4f73c2a.tar.gz
nissy-core-bdc7004014d3b62a72867bc78961feb7c4f73c2a.zip
Improved speed for esep table generation, but it is still slow. Changed moves names.
Diffstat (limited to '')
-rw-r--r--cube.c658
-rw-r--r--test/101_gendata_esep/00_all.in (renamed from test/101_gendata_eoesep/00_all.in)0
-rw-r--r--test/101_gendata_esep/00_all.out (renamed from test/101_gendata_eoesep/00_all.out)0
-rw-r--r--test/101_gendata_esep/gendata_esep_tests.c (renamed from test/101_gendata_eoesep/gendata_eoesep_tests.c)4
4 files changed, 333 insertions, 329 deletions
diff --git a/cube.c b/cube.c
index 2f000ce..02bbc63 100644
--- a/cube.c
+++ b/cube.c
@@ -59,74 +59,74 @@ _static int64_t binomial[12][12] = {
59Section: moves definitions and tables 59Section: moves definitions and tables
60******************************************************************************/ 60******************************************************************************/
61 61
62#define U 0U 62#define _move_U 0U
63#define U2 1U 63#define _move_U2 1U
64#define U3 2U 64#define _move_U3 2U
65#define D 3U 65#define _move_D 3U
66#define D2 4U 66#define _move_D2 4U
67#define D3 5U 67#define _move_D3 5U
68#define R 6U 68#define _move_R 6U
69#define R2 7U 69#define _move_R2 7U
70#define R3 8U 70#define _move_R3 8U
71#define L 9U 71#define _move_L 9U
72#define L2 10U 72#define _move_L2 10U
73#define L3 11U 73#define _move_L3 11U
74#define F 12U 74#define _move_F 12U
75#define F2 13U 75#define _move_F2 13U
76#define F3 14U 76#define _move_F3 14U
77#define B 15U 77#define _move_B 15U
78#define B2 16U 78#define _move_B2 16U
79#define B3 17U 79#define _move_B3 17U
80 80
81#define UFr 0 81#define _trans_UFr 0
82#define ULr 1 82#define _trans_ULr 1
83#define UBr 2 83#define _trans_UBr 2
84#define URr 3 84#define _trans_URr 3
85#define DFr 4 85#define _trans_DFr 4
86#define DLr 5 86#define _trans_DLr 5
87#define DBr 6 87#define _trans_DBr 6
88#define DRr 7 88#define _trans_DRr 7
89#define RUr 8 89#define _trans_RUr 8
90#define RFr 9 90#define _trans_RFr 9
91#define RDr 10 91#define _trans_RDr 10
92#define RBr 11 92#define _trans_RBr 11
93#define LUr 12 93#define _trans_LUr 12
94#define LFr 13 94#define _trans_LFr 13
95#define LDr 14 95#define _trans_LDr 14
96#define LBr 15 96#define _trans_LBr 15
97#define FUr 16 97#define _trans_FUr 16
98#define FRr 17 98#define _trans_FRr 17
99#define FDr 18 99#define _trans_FDr 18
100#define FLr 19 100#define _trans_FLr 19
101#define BUr 20 101#define _trans_BUr 20
102#define BRr 21 102#define _trans_BRr 21
103#define BDr 22 103#define _trans_BDr 22
104#define BLr 23 104#define _trans_BLr 23
105 105
106#define UFm 24 106#define _trans_UFm 24
107#define ULm 25 107#define _trans_ULm 25
108#define UBm 26 108#define _trans_UBm 26
109#define URm 27 109#define _trans_URm 27
110#define DFm 28 110#define _trans_DFm 28
111#define DLm 29 111#define _trans_DLm 29
112#define DBm 30 112#define _trans_DBm 30
113#define DRm 31 113#define _trans_DRm 31
114#define RUm 32 114#define _trans_RUm 32
115#define RFm 33 115#define _trans_RFm 33
116#define RDm 34 116#define _trans_RDm 34
117#define RBm 35 117#define _trans_RBm 35
118#define LUm 36 118#define _trans_LUm 36
119#define LFm 37 119#define _trans_LFm 37
120#define LDm 38 120#define _trans_LDm 38
121#define LBm 39 121#define _trans_LBm 39
122#define FUm 40 122#define _trans_FUm 40
123#define FRm 41 123#define _trans_FRm 41
124#define FDm 42 124#define _trans_FDm 42
125#define FLm 43 125#define _trans_FLm 43
126#define BUm 44 126#define _trans_BUm 44
127#define BRm 45 127#define _trans_BRm 45
128#define BDm 46 128#define _trans_BDm 46
129#define BLm 47 129#define _trans_BLm 47
130 130
131#define _c_ufr 0U 131#define _c_ufr 0U
132#define _c_ubl 1U 132#define _c_ubl 1U
@@ -444,126 +444,126 @@ _static const char *edgestr[] = {
444}; 444};
445 445
446_static const char *movestr[] = { 446_static const char *movestr[] = {
447 [U] = "U", 447 [_move_U] = "U",
448 [U2] = "U2", 448 [_move_U2] = "U2",
449 [U3] = "U'", 449 [_move_U3] = "U'",
450 [D] = "D", 450 [_move_D] = "D",
451 [D2] = "D2", 451 [_move_D2] = "D2",
452 [D3] = "D'", 452 [_move_D3] = "D'",
453 [R] = "R", 453 [_move_R] = "R",
454 [R2] = "R2", 454 [_move_R2] = "R2",
455 [R3] = "R'", 455 [_move_R3] = "R'",
456 [L] = "L", 456 [_move_L] = "L",
457 [L2] = "L2", 457 [_move_L2] = "L2",
458 [L3] = "L'", 458 [_move_L3] = "L'",
459 [F] = "F", 459 [_move_F] = "F",
460 [F2] = "F2", 460 [_move_F2] = "F2",
461 [F3] = "F'", 461 [_move_F3] = "F'",
462 [B] = "B", 462 [_move_B] = "B",
463 [B2] = "B2", 463 [_move_B2] = "B2",
464 [B3] = "B'", 464 [_move_B3] = "B'",
465}; 465};
466 466
467_static const char *transstr[] = { 467_static const char *transstr[] = {
468 [UFr] = "rotation UF", 468 [_trans_UFr] = "rotation UF",
469 [UFm] = "mirrored UF", 469 [_trans_UFm] = "mirrored UF",
470 [ULr] = "rotation UL", 470 [_trans_ULr] = "rotation UL",
471 [ULm] = "mirrored UL", 471 [_trans_ULm] = "mirrored UL",
472 [UBr] = "rotation UB", 472 [_trans_UBr] = "rotation UB",
473 [UBm] = "mirrored UB", 473 [_trans_UBm] = "mirrored UB",
474 [URr] = "rotation UR", 474 [_trans_URr] = "rotation UR",
475 [URm] = "mirrored UR", 475 [_trans_URm] = "mirrored UR",
476 [DFr] = "rotation DF", 476 [_trans_DFr] = "rotation DF",
477 [DFm] = "mirrored DF", 477 [_trans_DFm] = "mirrored DF",
478 [DLr] = "rotation DL", 478 [_trans_DLr] = "rotation DL",
479 [DLm] = "mirrored DL", 479 [_trans_DLm] = "mirrored DL",
480 [DBr] = "rotation DB", 480 [_trans_DBr] = "rotation DB",
481 [DBm] = "mirrored DB", 481 [_trans_DBm] = "mirrored DB",
482 [DRr] = "rotation DR", 482 [_trans_DRr] = "rotation DR",
483 [DRm] = "mirrored DR", 483 [_trans_DRm] = "mirrored DR",
484 [RUr] = "rotation RU", 484 [_trans_RUr] = "rotation RU",
485 [RUm] = "mirrored RU", 485 [_trans_RUm] = "mirrored RU",
486 [RFr] = "rotation RF", 486 [_trans_RFr] = "rotation RF",
487 [RFm] = "mirrored RF", 487 [_trans_RFm] = "mirrored RF",
488 [RDr] = "rotation RD", 488 [_trans_RDr] = "rotation RD",
489 [RDm] = "mirrored RD", 489 [_trans_RDm] = "mirrored RD",
490 [RBr] = "rotation RB", 490 [_trans_RBr] = "rotation RB",
491 [RBm] = "mirrored RB", 491 [_trans_RBm] = "mirrored RB",
492 [LUr] = "rotation LU", 492 [_trans_LUr] = "rotation LU",
493 [LUm] = "mirrored LU", 493 [_trans_LUm] = "mirrored LU",
494 [LFr] = "rotation LF", 494 [_trans_LFr] = "rotation LF",
495 [LFm] = "mirrored LF", 495 [_trans_LFm] = "mirrored LF",
496 [LDr] = "rotation LD", 496 [_trans_LDr] = "rotation LD",
497 [LDm] = "mirrored LD", 497 [_trans_LDm] = "mirrored LD",
498 [LBr] = "rotation LB", 498 [_trans_LBr] = "rotation LB",
499 [LBm] = "mirrored LB", 499 [_trans_LBm] = "mirrored LB",
500 [FUr] = "rotation FU", 500 [_trans_FUr] = "rotation FU",
501 [FUm] = "mirrored FU", 501 [_trans_FUm] = "mirrored FU",
502 [FRr] = "rotation FR", 502 [_trans_FRr] = "rotation FR",
503 [FRm] = "mirrored FR", 503 [_trans_FRm] = "mirrored FR",
504 [FDr] = "rotation FD", 504 [_trans_FDr] = "rotation FD",
505 [FDm] = "mirrored FD", 505 [_trans_FDm] = "mirrored FD",
506 [FLr] = "rotation FL", 506 [_trans_FLr] = "rotation FL",
507 [FLm] = "mirrored FL", 507 [_trans_FLm] = "mirrored FL",
508 [BUr] = "rotation BU", 508 [_trans_BUr] = "rotation BU",
509 [BUm] = "mirrored BU", 509 [_trans_BUm] = "mirrored BU",
510 [BRr] = "rotation BR", 510 [_trans_BRr] = "rotation BR",
511 [BRm] = "mirrored BR", 511 [_trans_BRm] = "mirrored BR",
512 [BDr] = "rotation BD", 512 [_trans_BDr] = "rotation BD",
513 [BDm] = "mirrored BD", 513 [_trans_BDm] = "mirrored BD",
514 [BLr] = "rotation BL", 514 [_trans_BLr] = "rotation BL",
515 [BLm] = "mirrored BL", 515 [_trans_BLm] = "mirrored BL",
516}; 516};
517 517
518static uint8_t inverse_trans_table[48] = { 518static uint8_t inverse_trans_table[48] = {
519 [UFr] = UFr, 519 [_trans_UFr] = _trans_UFr,
520 [UFm] = UFm, 520 [_trans_UFm] = _trans_UFm,
521 [ULr] = URr, 521 [_trans_ULr] = _trans_URr,
522 [ULm] = ULm, 522 [_trans_ULm] = _trans_ULm,
523 [UBr] = UBr, 523 [_trans_UBr] = _trans_UBr,
524 [UBm] = UBm, 524 [_trans_UBm] = _trans_UBm,
525 [URr] = ULr, 525 [_trans_URr] = _trans_ULr,
526 [URm] = URm, 526 [_trans_URm] = _trans_URm,
527 [DFr] = DFr, 527 [_trans_DFr] = _trans_DFr,
528 [DFm] = DFm, 528 [_trans_DFm] = _trans_DFm,
529 [DLr] = DLr, 529 [_trans_DLr] = _trans_DLr,
530 [DLm] = DRm, 530 [_trans_DLm] = _trans_DRm,
531 [DBr] = DBr, 531 [_trans_DBr] = _trans_DBr,
532 [DBm] = DBm, 532 [_trans_DBm] = _trans_DBm,
533 [DRr] = DRr, 533 [_trans_DRr] = _trans_DRr,
534 [DRm] = DLm, 534 [_trans_DRm] = _trans_DLm,
535 [RUr] = FRr, 535 [_trans_RUr] = _trans_FRr,
536 [RUm] = FLm, 536 [_trans_RUm] = _trans_FLm,
537 [RFr] = LFr, 537 [_trans_RFr] = _trans_LFr,
538 [RFm] = RFm, 538 [_trans_RFm] = _trans_RFm,
539 [RDr] = BLr, 539 [_trans_RDr] = _trans_BLr,
540 [RDm] = BRm, 540 [_trans_RDm] = _trans_BRm,
541 [RBr] = RBr, 541 [_trans_RBr] = _trans_RBr,
542 [RBm] = LBm, 542 [_trans_RBm] = _trans_LBm,
543 [LUr] = FLr, 543 [_trans_LUr] = _trans_FLr,
544 [LUm] = FRm, 544 [_trans_LUm] = _trans_FRm,
545 [LFr] = RFr, 545 [_trans_LFr] = _trans_RFr,
546 [LFm] = LFm, 546 [_trans_LFm] = _trans_LFm,
547 [LDr] = BRr, 547 [_trans_LDr] = _trans_BRr,
548 [LDm] = BLm, 548 [_trans_LDm] = _trans_BLm,
549 [LBr] = LBr, 549 [_trans_LBr] = _trans_LBr,
550 [LBm] = RBm, 550 [_trans_LBm] = _trans_RBm,
551 [FUr] = FUr, 551 [_trans_FUr] = _trans_FUr,
552 [FUm] = FUm, 552 [_trans_FUm] = _trans_FUm,
553 [FRr] = RUr, 553 [_trans_FRr] = _trans_RUr,
554 [FRm] = LUm, 554 [_trans_FRm] = _trans_LUm,
555 [FDr] = BUr, 555 [_trans_FDr] = _trans_BUr,
556 [FDm] = BUm, 556 [_trans_FDm] = _trans_BUm,
557 [FLr] = LUr, 557 [_trans_FLr] = _trans_LUr,
558 [FLm] = RUm, 558 [_trans_FLm] = _trans_RUm,
559 [BUr] = FDr, 559 [_trans_BUr] = _trans_FDr,
560 [BUm] = FDm, 560 [_trans_BUm] = _trans_FDm,
561 [BRr] = LDr, 561 [_trans_BRr] = _trans_LDr,
562 [BRm] = RDm, 562 [_trans_BRm] = _trans_RDm,
563 [BDr] = BDr, 563 [_trans_BDr] = _trans_BDr,
564 [BDm] = BDm, 564 [_trans_BDm] = _trans_BDm,
565 [BLr] = RDr, 565 [_trans_BLr] = _trans_RDr,
566 [BLm] = LDm, 566 [_trans_BLm] = _trans_LDm,
567}; 567};
568 568
569/****************************************************************************** 569/******************************************************************************
@@ -1572,17 +1572,17 @@ readmove(char c)
1572{ 1572{
1573 switch (c) { 1573 switch (c) {
1574 case 'U': 1574 case 'U':
1575 return U; 1575 return _move_U;
1576 case 'D': 1576 case 'D':
1577 return D; 1577 return _move_D;
1578 case 'R': 1578 case 'R':
1579 return R; 1579 return _move_R;
1580 case 'L': 1580 case 'L':
1581 return L; 1581 return _move_L;
1582 case 'F': 1582 case 'F':
1583 return F; 1583 return _move_F;
1584 case 'B': 1584 case 'B':
1585 return B; 1585 return _move_B;
1586 default: 1586 default:
1587 return _error; 1587 return _error;
1588 } 1588 }
@@ -1653,41 +1653,41 @@ _static cube_fast_t
1653move(cube_fast_t c, uint8_t m) 1653move(cube_fast_t c, uint8_t m)
1654{ 1654{
1655 switch (m) { 1655 switch (m) {
1656 case U: 1656 case _move_U:
1657 return _move(U, c); 1657 return _move(U, c);
1658 case U2: 1658 case _move_U2:
1659 return _move(U2, c); 1659 return _move(U2, c);
1660 case U3: 1660 case _move_U3:
1661 return _move(U3, c); 1661 return _move(U3, c);
1662 case D: 1662 case _move_D:
1663 return _move(D, c); 1663 return _move(D, c);
1664 case D2: 1664 case _move_D2:
1665 return _move(D2, c); 1665 return _move(D2, c);
1666 case D3: 1666 case _move_D3:
1667 return _move(D3, c); 1667 return _move(D3, c);
1668 case R: 1668 case _move_R:
1669 return _move(R, c); 1669 return _move(R, c);
1670 case R2: 1670 case _move_R2:
1671 return _move(R2, c); 1671 return _move(R2, c);
1672 case R3: 1672 case _move_R3:
1673 return _move(R3, c); 1673 return _move(R3, c);
1674 case L: 1674 case _move_L:
1675 return _move(L, c); 1675 return _move(L, c);
1676 case L2: 1676 case _move_L2:
1677 return _move(L2, c); 1677 return _move(L2, c);
1678 case L3: 1678 case _move_L3:
1679 return _move(L3, c); 1679 return _move(L3, c);
1680 case F: 1680 case _move_F:
1681 return _move(F, c); 1681 return _move(F, c);
1682 case F2: 1682 case _move_F2:
1683 return _move(F2, c); 1683 return _move(F2, c);
1684 case F3: 1684 case _move_F3:
1685 return _move(F3, c); 1685 return _move(F3, c);
1686 case B: 1686 case _move_B:
1687 return _move(B, c); 1687 return _move(B, c);
1688 case B2: 1688 case _move_B2:
1689 return _move(B2, c); 1689 return _move(B2, c);
1690 case B3: 1690 case _move_B3:
1691 return _move(B3, c); 1691 return _move(B3, c);
1692 default: 1692 default:
1693 DBG_LOG("move error, unknown move\n"); 1693 DBG_LOG("move error, unknown move\n");
@@ -1699,101 +1699,101 @@ _static cube_fast_t
1699transform(cube_fast_t c, uint8_t t) 1699transform(cube_fast_t c, uint8_t t)
1700{ 1700{
1701 switch (t) { 1701 switch (t) {
1702 case UFr: 1702 case _trans_UFr:
1703 return _trans_rotation(UFr, c); 1703 return _trans_rotation(UFr, c);
1704 case ULr: 1704 case _trans_ULr:
1705 return _trans_rotation(ULr, c); 1705 return _trans_rotation(ULr, c);
1706 case UBr: 1706 case _trans_UBr:
1707 return _trans_rotation(UBr, c); 1707 return _trans_rotation(UBr, c);
1708 case URr: 1708 case _trans_URr:
1709 return _trans_rotation(URr, c); 1709 return _trans_rotation(URr, c);
1710 case DFr: 1710 case _trans_DFr:
1711 return _trans_rotation(DFr, c); 1711 return _trans_rotation(DFr, c);
1712 case DLr: 1712 case _trans_DLr:
1713 return _trans_rotation(DLr, c); 1713 return _trans_rotation(DLr, c);
1714 case DBr: 1714 case _trans_DBr:
1715 return _trans_rotation(DBr, c); 1715 return _trans_rotation(DBr, c);
1716 case DRr: 1716 case _trans_DRr:
1717 return _trans_rotation(DRr, c); 1717 return _trans_rotation(DRr, c);
1718 case RUr: 1718 case _trans_RUr:
1719 return _trans_rotation(RUr, c); 1719 return _trans_rotation(RUr, c);
1720 case RFr: 1720 case _trans_RFr:
1721 return _trans_rotation(RFr, c); 1721 return _trans_rotation(RFr, c);
1722 case RDr: 1722 case _trans_RDr:
1723 return _trans_rotation(RDr, c); 1723 return _trans_rotation(RDr, c);
1724 case RBr: 1724 case _trans_RBr:
1725 return _trans_rotation(RBr, c); 1725 return _trans_rotation(RBr, c);
1726 case LUr: 1726 case _trans_LUr:
1727 return _trans_rotation(LUr, c); 1727 return _trans_rotation(LUr, c);
1728 case LFr: 1728 case _trans_LFr:
1729 return _trans_rotation(LFr, c); 1729 return _trans_rotation(LFr, c);
1730 case LDr: 1730 case _trans_LDr:
1731 return _trans_rotation(LDr, c); 1731 return _trans_rotation(LDr, c);
1732 case LBr: 1732 case _trans_LBr:
1733 return _trans_rotation(LBr, c); 1733 return _trans_rotation(LBr, c);
1734 case FUr: 1734 case _trans_FUr:
1735 return _trans_rotation(FUr, c); 1735 return _trans_rotation(FUr, c);
1736 case FRr: 1736 case _trans_FRr:
1737 return _trans_rotation(FRr, c); 1737 return _trans_rotation(FRr, c);
1738 case FDr: 1738 case _trans_FDr:
1739 return _trans_rotation(FDr, c); 1739 return _trans_rotation(FDr, c);
1740 case FLr: 1740 case _trans_FLr:
1741 return _trans_rotation(FLr, c); 1741 return _trans_rotation(FLr, c);
1742 case BUr: 1742 case _trans_BUr:
1743 return _trans_rotation(BUr, c); 1743 return _trans_rotation(BUr, c);
1744 case BRr: 1744 case _trans_BRr:
1745 return _trans_rotation(BRr, c); 1745 return _trans_rotation(BRr, c);
1746 case BDr: 1746 case _trans_BDr:
1747 return _trans_rotation(BDr, c); 1747 return _trans_rotation(BDr, c);
1748 case BLr: 1748 case _trans_BLr:
1749 return _trans_rotation(BLr, c); 1749 return _trans_rotation(BLr, c);
1750 case UFm: 1750 case _trans_UFm:
1751 return _trans_mirrored(UFm, c); 1751 return _trans_mirrored(UFm, c);
1752 case ULm: 1752 case _trans_ULm:
1753 return _trans_mirrored(ULm, c); 1753 return _trans_mirrored(ULm, c);
1754 case UBm: 1754 case _trans_UBm:
1755 return _trans_mirrored(UBm, c); 1755 return _trans_mirrored(UBm, c);
1756 case URm: 1756 case _trans_URm:
1757 return _trans_mirrored(URm, c); 1757 return _trans_mirrored(URm, c);
1758 case DFm: 1758 case _trans_DFm:
1759 return _trans_mirrored(DFm, c); 1759 return _trans_mirrored(DFm, c);
1760 case DLm: 1760 case _trans_DLm:
1761 return _trans_mirrored(DLm, c); 1761 return _trans_mirrored(DLm, c);
1762 case DBm: 1762 case _trans_DBm:
1763 return _trans_mirrored(DBm, c); 1763 return _trans_mirrored(DBm, c);
1764 case DRm: 1764 case _trans_DRm:
1765 return _trans_mirrored(DRm, c); 1765 return _trans_mirrored(DRm, c);
1766 case RUm: 1766 case _trans_RUm:
1767 return _trans_mirrored(RUm, c); 1767 return _trans_mirrored(RUm, c);
1768 case RFm: 1768 case _trans_RFm:
1769 return _trans_mirrored(RFm, c); 1769 return _trans_mirrored(RFm, c);
1770 case RDm: 1770 case _trans_RDm:
1771 return _trans_mirrored(RDm, c); 1771 return _trans_mirrored(RDm, c);
1772 case RBm: 1772 case _trans_RBm:
1773 return _trans_mirrored(RBm, c); 1773 return _trans_mirrored(RBm, c);
1774 case LUm: 1774 case _trans_LUm:
1775 return _trans_mirrored(LUm, c); 1775 return _trans_mirrored(LUm, c);
1776 case LFm: 1776 case _trans_LFm:
1777 return _trans_mirrored(LFm, c); 1777 return _trans_mirrored(LFm, c);
1778 case LDm: 1778 case _trans_LDm:
1779 return _trans_mirrored(LDm, c); 1779 return _trans_mirrored(LDm, c);
1780 case LBm: 1780 case _trans_LBm:
1781 return _trans_mirrored(LBm, c); 1781 return _trans_mirrored(LBm, c);
1782 case FUm: 1782 case _trans_FUm:
1783 return _trans_mirrored(FUm, c); 1783 return _trans_mirrored(FUm, c);
1784 case FRm: 1784 case _trans_FRm:
1785 return _trans_mirrored(FRm, c); 1785 return _trans_mirrored(FRm, c);
1786 case FDm: 1786 case _trans_FDm:
1787 return _trans_mirrored(FDm, c); 1787 return _trans_mirrored(FDm, c);
1788 case FLm: 1788 case _trans_FLm:
1789 return _trans_mirrored(FLm, c); 1789 return _trans_mirrored(FLm, c);
1790 case BUm: 1790 case _trans_BUm:
1791 return _trans_mirrored(BUm, c); 1791 return _trans_mirrored(BUm, c);
1792 case BRm: 1792 case _trans_BRm:
1793 return _trans_mirrored(BRm, c); 1793 return _trans_mirrored(BRm, c);
1794 case BDm: 1794 case _trans_BDm:
1795 return _trans_mirrored(BDm, c); 1795 return _trans_mirrored(BDm, c);
1796 case BLm: 1796 case _trans_BLm:
1797 return _trans_mirrored(BLm, c); 1797 return _trans_mirrored(BLm, c);
1798 default: 1798 default:
1799 DBG_LOG("transform error, unknown transformation\n"); 1799 DBG_LOG("transform error, unknown transformation\n");
@@ -1886,13 +1886,18 @@ moveaxis(uint8_t move)
1886Section: auxiliary procedures for H48 optimal solver (temporary) 1886Section: auxiliary procedures for H48 optimal solver (temporary)
1887******************************************************************************/ 1887******************************************************************************/
1888 1888
1889#define _esep_ind(i) (i / 8U)
1890#define _esep_shift(i) (4U * (i % 8U))
1891#define _esep_mask(i) (((1U << 4U) - 1U) << _esep_shift(i))
1892#define _visited_ind(i) (i / 8U)
1893#define _visited_mask(i) (1U << (i % 8U))
1894
1889typedef struct { 1895typedef struct {
1890 cube_fast_t cube; 1896 cube_fast_t cube;
1897 uint8_t *visited;
1891 uint8_t *moves; 1898 uint8_t *moves;
1892 uint8_t nmoves; 1899 uint8_t nmoves;
1893 uint8_t depth; 1900 uint8_t depth;
1894 uint8_t h;
1895 uint8_t k;
1896 uint16_t *nclasses; 1901 uint16_t *nclasses;
1897 uint32_t *cocsepdata; 1902 uint32_t *cocsepdata;
1898 uint32_t *buf32; 1903 uint32_t *buf32;
@@ -1900,13 +1905,15 @@ typedef struct {
1900 1905
1901_static size_t gendata_cocsep(void *); 1906_static size_t gendata_cocsep(void *);
1902_static uint32_t gendata_cocsep_dfs( /* TODO: use dfsarg */ 1907_static uint32_t gendata_cocsep_dfs( /* TODO: use dfsarg */
1903 cube_fast_t, uint8_t, uint8_t, uint16_t *, uint32_t *, bool *); 1908 cube_fast_t, uint8_t, uint8_t, uint16_t *, uint32_t *, uint8_t *);
1904 1909
1905_static size_t gendata_eoesep(uint8_t, uint8_t, const void *, void *); 1910_static size_t gendata_esep(const void *, void *);
1906_static uint32_t gendata_eoesep_dfs(dfsarg_gendata_t *); 1911_static uint32_t gendata_esep_dfs(dfsarg_gendata_t *);
1907 1912
1908_static_inline uint8_t get_h48_pval(const uint32_t *, int64_t, uint8_t); 1913_static_inline bool get_visited(const uint8_t *, int64_t);
1909_static_inline void set_h48_pval(uint32_t *, int64_t, uint8_t, uint8_t); 1914_static_inline void set_visited(uint8_t *, int64_t);
1915_static_inline uint8_t get_esep_pval(const uint32_t *, int64_t);
1916_static_inline void set_esep_pval(uint32_t *, int64_t, uint8_t);
1910 1917
1911/* 1918/*
1912Each element of the cocsep table is a uint32_t used as follows: 1919Each element of the cocsep table is a uint32_t used as follows:
@@ -1922,14 +1929,14 @@ After the data as described above, more auxiliary information is appended:
1922_static size_t 1929_static size_t
1923gendata_cocsep(void *buf) 1930gendata_cocsep(void *buf)
1924{ 1931{
1925 static size_t tablesize = _3p7 << 7U; 1932 size_t tablesize = _3p7 << 7U;
1926 static size_t infosize = 12; 1933 size_t visitedsize = (tablesize + 7U) / 8U;
1934 size_t infosize = 12;
1927 1935
1928 cube_fast_t solved; 1936 cube_fast_t solved;
1929 uint32_t *buf32, *info, cc; 1937 uint32_t *buf32, *info, cc;
1930 uint16_t n; 1938 uint16_t n;
1931 uint8_t i, j; 1939 uint8_t i, j, visited[visitedsize];
1932 bool visited[tablesize];
1933 1940
1934 buf32 = (uint32_t *)buf; 1941 buf32 = (uint32_t *)buf;
1935 info = buf32 + tablesize; 1942 info = buf32 + tablesize;
@@ -1938,12 +1945,13 @@ gendata_cocsep(void *buf)
1938 1945
1939 solved = cubetofast(solvedcube()); 1946 solved = cubetofast(solvedcube());
1940 for (i = 0, n = 0, cc = 0; i < 10; i++) { 1947 for (i = 0, n = 0, cc = 0; i < 10; i++) {
1941 memset(visited, 0, tablesize * sizeof(bool)); 1948 memset(visited, 0, visitedsize);
1942 DBG_LOG("gendata_cocsep: generating depth %" PRIu8 "\n", i); 1949 DBG_LOG("cocsep: generating depth %" PRIu8 "\n", i);
1943 cc = gendata_cocsep_dfs(solved, 0, i, &n, buf32, visited); 1950 cc = gendata_cocsep_dfs(solved, 0, i, &n, buf32, visited);
1944 info[i+2] = cc; 1951 info[i+2] = cc;
1945 DBG_LOG("found %" PRIu32 "\n", cc); 1952 DBG_LOG("found %" PRIu32 "\n", cc);
1946 } 1953 }
1954
1947 info[0] = (uint32_t)n; 1955 info[0] = (uint32_t)n;
1948 info[1] = 9U; /* Known max pruning value */ 1956 info[1] = 9U; /* Known max pruning value */
1949 DBG_ASSERT(n == COCSEP_CLASSES, 0, 1957 DBG_ASSERT(n == COCSEP_CLASSES, 0,
@@ -1967,29 +1975,28 @@ gendata_cocsep_dfs(
1967 uint8_t maxdepth, 1975 uint8_t maxdepth,
1968 uint16_t *n, 1976 uint16_t *n,
1969 uint32_t *buf32, 1977 uint32_t *buf32,
1970 bool *visited 1978 uint8_t *visited
1971) 1979)
1972{ 1980{
1973 uint8_t m, t, tinv, olddepth; 1981 uint8_t m, t, tinv, olddepth;
1974 uint32_t cc; 1982 uint32_t cc;
1975 uint64_t i; 1983 int64_t i;
1976 cube_fast_t d; 1984 cube_fast_t d;
1977 1985
1978 i = coord_fast_cocsep(c); 1986 i = coord_fast_cocsep(c);
1979 olddepth = (uint8_t)(buf32[i] & 0xFFU); 1987 olddepth = (uint8_t)(buf32[i] & 0xFFU);
1980 if (olddepth < depth || visited[i]) 1988 if (olddepth < depth || get_visited(visited, i))
1981 return 0; 1989 return 0;
1982 visited[i] = true; 1990 set_visited(visited, i);
1983 1991
1984 if (depth == maxdepth) { 1992 if (depth == maxdepth) {
1985 if ((buf32[i] & 0xFFU) != 0xFFU) 1993 if ((buf32[i] & 0xFFU) != 0xFFU)
1986 return 0; 1994 return 0;
1987 1995
1988 cc = 0; 1996 for (t = 0, cc = 0; t < 48; t++) {
1989 for (t = 0; t < 48; t++) {
1990 d = transform(c, t); 1997 d = transform(c, t);
1991 i = coord_fast_cocsep(d); 1998 i = coord_fast_cocsep(d);
1992 visited[i] = true; 1999 set_visited(visited, i);
1993 tinv = inverse_trans(t); 2000 tinv = inverse_trans(t);
1994 cc += (buf32[i] & 0xFFU) == 0xFFU; 2001 cc += (buf32[i] & 0xFFU) == 0xFFU;
1995 buf32[i] = (*n << 16U) | (tinv << 8U) | depth; 2002 buf32[i] = (*n << 16U) | (tinv << 8U) | depth;
@@ -2009,21 +2016,20 @@ gendata_cocsep_dfs(
2009 2016
2010/* 2017/*
2011TODO description 2018TODO description
2012h is the number of eo bits 2019generating fixed table with h=0, k=4
2013k is the compression size (4, 2 or 1 bit)
2014*/ 2020*/
2015_static size_t 2021_static size_t
2016gendata_eoesep(uint8_t h, uint8_t k, const void *cocsepdata, void *buf) 2022gendata_esep(const void *cocsepdata, void *buf)
2017{ 2023{
2018 DBG_ASSERT(k == 4, 0, "eoesep: only k=4 is supported"); 2024 size_t tablesize = (COCSEP_CLASSES * _12c4 * _8c4) / 2U;
2019 2025 size_t visitedsize = (tablesize * 2U + 7U) / 8U;
2020 size_t tablesize = ((COCSEP_CLASSES * _12c4 * _8c4) / (8U / k)) << h;
2021 size_t infosize = 25; /* TODO unknown yet */ 2026 size_t infosize = 25; /* TODO unknown yet */
2022 2027
2023 uint32_t *buf32, *info, cc; 2028 uint32_t *buf32, *info, cc;
2024 uint8_t moves[20]; 2029 uint8_t moves[20];
2025 dfsarg_gendata_t arg; 2030 dfsarg_gendata_t arg;
2026 2031
2032 arg.visited = malloc(visitedsize);
2027 buf32 = (uint32_t *)buf; 2033 buf32 = (uint32_t *)buf;
2028 info = buf32 + tablesize; 2034 info = buf32 + tablesize;
2029 memset(buf32, 0xFFU, 4*tablesize); 2035 memset(buf32, 0xFFU, 4*tablesize);
@@ -2032,64 +2038,28 @@ gendata_eoesep(uint8_t h, uint8_t k, const void *cocsepdata, void *buf)
2032 arg.cube = cubetofast(solvedcube()); 2038 arg.cube = cubetofast(solvedcube());
2033 arg.moves = moves; 2039 arg.moves = moves;
2034 arg.nmoves = 0; 2040 arg.nmoves = 0;
2035 arg.h = h;
2036 arg.k = k;
2037 arg.cocsepdata = (uint32_t *)cocsepdata; 2041 arg.cocsepdata = (uint32_t *)cocsepdata;
2038 arg.buf32 = buf32; 2042 arg.buf32 = buf32;
2039 /* TODO loop until no more is done, not until 12! (or hardcode limits)*/ 2043 /* TODO loop until no more is done, not until 12! (or hardcode limits)*/
2040 for (arg.depth = 0, cc = 0; arg.depth < 12; arg.depth++) { 2044 for (arg.depth = 0, cc = 0; arg.depth < 12; arg.depth++) {
2041 DBG_LOG("gendata_eoesep: generating depth %" PRIu8 "\n", 2045 DBG_LOG("esep: generating depth %" PRIu8 "\n", arg.depth);
2042 arg.depth); 2046 memset(arg.visited, 0, visitedsize);
2043 cc = gendata_eoesep_dfs(&arg); 2047 cc = gendata_esep_dfs(&arg);
2044 info[arg.depth+1] = cc; 2048 info[arg.depth+1] = cc;
2045 DBG_LOG("found %" PRIu32 "\n", cc); 2049 DBG_LOG("found %" PRIu32 "\n", cc);
2046 } 2050 }
2051 free(arg.visited);
2047 2052
2048 return cc; 2053 return cc;
2049} 2054}
2050 2055
2051_static_inline uint8_t
2052get_h48_pval(const uint32_t *buf32, int64_t index, uint8_t k)
2053{
2054 uint32_t mask, shift;
2055 int64_t realindex, subindex;
2056
2057 DBG_ASSERT(k == 1 || k == 2 || k == 4, 0,
2058 "h48 coordinate invalid k=%" PRIu8 "\n", k);
2059
2060 /* TODO: use more efficient operations, pass k as exponent */
2061 realindex = index / (32 / k);
2062 subindex = index % (32 / k);
2063 shift = (uint8_t)(k * subindex);
2064 mask = ((1U << k) - 1U) << shift;
2065
2066 return (buf32[realindex] & mask) >> shift;
2067}
2068
2069_static_inline void
2070set_h48_pval(uint32_t *buf32, int64_t index, uint8_t k, uint8_t val)
2071{
2072 uint32_t mask, shift;
2073 int64_t realindex, subindex;
2074
2075 DBG_ASSERT(k == 1 || k == 2 || k == 4, ,
2076 "h48 coordinate invalid k=%" PRIu8 "\n", k);
2077
2078 /* TODO: use more efficient operations, pass k as exponent */
2079 realindex = index / (32 / k);
2080 subindex = index % (32 / k);
2081 shift = (uint8_t)(k * subindex);
2082 mask = ((1U << k) - 1U) << shift;
2083
2084 buf32[realindex] = (buf32[realindex] & (~mask)) | (val << shift);
2085}
2086
2087_static uint32_t 2056_static uint32_t
2088gendata_eoesep_dfs(dfsarg_gendata_t *arg) 2057gendata_esep_dfs(dfsarg_gendata_t *arg)
2089{ 2058{
2090 uint8_t m, olddepth; 2059 uint8_t m, t, olddepth;
2091 uint32_t cc; 2060 uint32_t cc;
2092 uint64_t i; 2061 uint64_t i;
2062 cube_fast_t d;
2093 dfsarg_gendata_t nextarg; 2063 dfsarg_gendata_t nextarg;
2094 2064
2095 if (!allowednextmove(arg->moves, arg->nmoves)) 2065 if (!allowednextmove(arg->moves, arg->nmoves))
@@ -2098,29 +2068,63 @@ gendata_eoesep_dfs(dfsarg_gendata_t *arg)
2098 if (arg->nmoves > 0) 2068 if (arg->nmoves > 0)
2099 arg->cube = move(arg->cube, arg->moves[arg->nmoves-1]); 2069 arg->cube = move(arg->cube, arg->moves[arg->nmoves-1]);
2100 2070
2101 i = coord_h48(arg->cube, arg->cocsepdata, arg->h); 2071 i = coord_h48(arg->cube, arg->cocsepdata, 0U);
2102 olddepth = get_h48_pval(arg->buf32, i, arg->k); 2072 olddepth = get_esep_pval(arg->buf32, i);
2103 2073
2104 if (olddepth < arg->nmoves) 2074 if (olddepth < arg->nmoves || get_visited(arg->visited, i))
2105 return 0; 2075 return 0;
2076 set_visited(arg->visited, i);
2106 2077
2107 if (arg->nmoves == arg->depth) { 2078 if (arg->nmoves == arg->depth) {
2108 cc = olddepth > arg->depth; 2079 if (olddepth != 15U)
2109 set_h48_pval(arg->buf32, i, arg->k, arg->depth); 2080 return 0;
2081
2082 for (t = 0, cc = 0; t < 48; t++) {
2083 d = transform(arg->cube, t);
2084 i = coord_h48(d, arg->cocsepdata, 0U);
2085 set_visited(arg->visited, i);
2086 cc += get_esep_pval(arg->buf32, i) == 15U;
2087 set_esep_pval(arg->buf32, i, arg->depth);
2088 }
2089
2110 return cc; 2090 return cc;
2111 } 2091 }
2112 2092
2093
2113 nextarg = *arg; 2094 nextarg = *arg;
2114 nextarg.nmoves = arg->nmoves + 1; 2095 nextarg.nmoves = arg->nmoves + 1;
2115 for (m = 0, cc = 0; m < 18; m++) { 2096 for (m = 0, cc = 0; m < 18; m++) {
2116 nextarg.cube = arg->cube; 2097 nextarg.cube = arg->cube;
2117 nextarg.moves[arg->nmoves] = m; 2098 nextarg.moves[arg->nmoves] = m;
2118 cc += gendata_eoesep_dfs(&nextarg); 2099 cc += gendata_esep_dfs(&nextarg);
2119 } 2100 }
2120 2101
2121 return cc; 2102 return cc;
2122} 2103}
2123 2104
2105_static_inline bool get_visited(const uint8_t *a, int64_t i)
2106{
2107 return a[_visited_ind(i)] & _visited_mask(i);
2108}
2109
2110_static_inline void set_visited(uint8_t *a, int64_t i)
2111{
2112 a[_visited_ind(i)] |= _visited_mask(i);
2113}
2114
2115_static_inline uint8_t
2116get_esep_pval(const uint32_t *buf32, int64_t i)
2117{
2118 return (buf32[_esep_ind(i)] & _esep_mask(i)) >> _esep_shift(i);
2119}
2120
2121_static_inline void
2122set_esep_pval(uint32_t *buf32, int64_t i, uint8_t val)
2123{
2124 buf32[_esep_ind(i)] =
2125 (buf32[_esep_ind(i)] & (~_esep_mask(i))) | (val << _esep_shift(i));
2126}
2127
2124/****************************************************************************** 2128/******************************************************************************
2125Section: solvers 2129Section: solvers
2126 2130
diff --git a/test/101_gendata_eoesep/00_all.in b/test/101_gendata_esep/00_all.in
index e69de29..e69de29 100644
--- a/test/101_gendata_eoesep/00_all.in
+++ b/test/101_gendata_esep/00_all.in
diff --git a/test/101_gendata_eoesep/00_all.out b/test/101_gendata_esep/00_all.out
index deba01f..deba01f 100644
--- a/test/101_gendata_eoesep/00_all.out
+++ b/test/101_gendata_esep/00_all.out
diff --git a/test/101_gendata_eoesep/gendata_eoesep_tests.c b/test/101_gendata_esep/gendata_esep_tests.c
index e03e95d..bc7ce25 100644
--- a/test/101_gendata_eoesep/gendata_eoesep_tests.c
+++ b/test/101_gendata_esep/gendata_esep_tests.c
@@ -7,14 +7,14 @@ uint32_t buf_c[CSIZE/4];
7uint32_t buf_e[ESIZE/4]; 7uint32_t buf_e[ESIZE/4];
8 8
9size_t gendata_cocsep(void *); 9size_t gendata_cocsep(void *);
10size_t gendata_eoesep(uint8_t, uint8_t, const void *, void *); 10size_t gendata_esep(const void *, void *);
11 11
12int main(void) { 12int main(void) {
13 uint32_t i; 13 uint32_t i;
14 size_t result; 14 size_t result;
15 15
16 gendata_cocsep(buf_c); 16 gendata_cocsep(buf_c);
17 result = gendata_eoesep(0U, 4U, buf_c, buf_e); 17 result = gendata_esep(buf_c, buf_e);
18 18
19 printf("nothing\n"); 19 printf("nothing\n");
20 20

Generated with cgit - Back to sebastiano.tronto.net