20 for (
int x = 0; x < 12; x++)
30 for (
int x = 0; x < 18; x++)
33 neighbors.push_back(s);
40 for (
int x = 0; x < 18; x++)
338 { 1ll, 1ll, 2ll, 6ll, 24ll, 120ll, 720ll, 5040ll, 40320ll, 362880ll, 3628800ll, 39916800ll, 479001600ll,
339 6227020800ll, 87178291200ll, 1307674368000ll, 20922789888000ll, 355687428096000ll,
340 6402373705728000ll, 121645100408832000ll, 2432902008176640000ll };
345 inline int get(uint64_t state,
int whichLoc)
348 return (state>>((whichLoc<<2)))&0xF;
351 inline void set(uint64_t &state,
int whichLoc,
int cube)
353 const uint64_t blank = 0xF;
354 uint64_t value = cube;
355 state = state&(~(blank<<((whichLoc<<2))));
356 state |= (value<<((whichLoc<<2)));
359 inline void swap(uint64_t &state,
int loc1,
int loc2)
363 uint64_t val1 = (state>>(loc1))&0xF;
364 uint64_t val2 = (state>>(loc2))&0xF;
365 const uint64_t blank = 0xF;
366 uint64_t mask = (blank<<(loc1))|(blank<<(loc2));
367 state = state&(~mask);
368 state = state|(val1<<(loc2))|(val2<<(loc1));
374 { 1ll, 1ll, 2ll, 6ll, 24ll, 120ll, 720ll, 5040ll, 40320ll, 362880ll, 3628800ll, 39916800ll, 479001600ll,
375 6227020800ll, 87178291200ll, 1307674368000ll, 20922789888000ll, 355687428096000ll,
376 6402373705728000ll, 121645100408832000ll, 2432902008176640000ll };
402 for (
unsigned int x = 0; x <
pieces; x++)
405 hash1 = (hash1<<1)+
node.GetCubeOrientation(x);
414 for (
int x = 0; x < 12; x++)
418 locs[
node.GetCubeInLoc(x)] = x;
423 int numEntriesLeft = 12;
424 for (
unsigned int x = 0; x <
pieces; x++)
428 for (
unsigned y = x+1; y <
pieces; y++)
430 if (locs[y] > locs[x])
442 for (
int x = 0; x < 12; x++)
446 locs[
node.GetCubeInLoc(x)] = x;
449 for (
unsigned int x = 0; x <
pieces; x++)
451 hash1 = (hash1<<1)+
node.GetCubeOrientation(x);
455 int numEntriesLeft = 12;
456 for (
unsigned int x = 0; x <
pieces; x++)
460 for (
unsigned y = x+1; y <
pieces; y++)
462 if (locs[y] > locs[x])
478 int numEntriesLeft = 12-
pieces+2;
479 for (
int x =
pieces-1; x >= 0; x--)
487 locs[x] = (int)(hash2%(numEntriesLeft-1));
488 hash2 = hash2/(numEntriesLeft-1);
493 for (
unsigned y = x+1; y <
pieces; y++)
495 if (locs[y] >= locs[x])
508 for (
int x = 0; x < 12; x++)
510 node.SetCubeInLoc(x, 0xF);
513 for (
int x =
pieces-1; x >= 0; x--)
515 node.SetCubeInLoc(locs[x], x);
521 for (
int x = 0; x < 12; x++)
523 if (
node.GetCubeInLoc(x) == 0xF)
524 node.SetCubeInLoc(x, next++);
538 float offset = 2.0*scale/3.0;
545 glVertex3f(-scale, -scale, offset/2.0);
546 glVertex3f(-scale, -scale, -offset/2.0);
547 glVertex3f(-scale+offset, -scale, -offset/2.0);
548 glVertex3f(-scale+offset, -scale, offset/2.0);
552 glVertex3f(scale, -scale, offset/2.0);
553 glVertex3f(scale, -scale, -offset/2.0);
554 glVertex3f(scale-offset, -scale, -offset/2.0);
555 glVertex3f(scale-offset, -scale, offset/2.0);
559 glVertex3f(-offset/2.0, -scale, -scale);
560 glVertex3f(-offset/2.0, -scale, -scale+offset);
561 glVertex3f(offset/2.0, -scale, -scale+offset);
562 glVertex3f(offset/2.0, -scale, -scale);
566 glVertex3f(-offset/2.0, -scale, scale);
567 glVertex3f(-offset/2.0, -scale, scale-offset);
568 glVertex3f(offset/2.0, -scale, scale-offset);
569 glVertex3f(offset/2.0, -scale, scale);
574 glVertex3f(-scale, scale, offset/2.0);
575 glVertex3f(-scale, scale, -offset/2.0);
576 glVertex3f(-scale+offset, scale, -offset/2.0);
577 glVertex3f(-scale+offset, scale, offset/2.0);
581 glVertex3f(scale, scale, offset/2.0);
582 glVertex3f(scale, scale, -offset/2.0);
583 glVertex3f(scale-offset, scale, -offset/2.0);
584 glVertex3f(scale-offset, scale, offset/2.0);
588 glVertex3f(-offset/2.0, scale, -scale);
589 glVertex3f(-offset/2.0, scale, -scale+offset);
590 glVertex3f(offset/2.0, scale, -scale+offset);
591 glVertex3f(offset/2.0, scale, -scale);
595 glVertex3f(-offset/2.0, scale, scale);
596 glVertex3f(-offset/2.0, scale, scale-offset);
597 glVertex3f(offset/2.0, scale, scale-offset);
598 glVertex3f(offset/2.0, scale, scale);
603 glVertex3f(-scale, -scale+offset, -offset/2.0);
604 glVertex3f(-scale, -scale+offset, offset/2.0);
605 glVertex3f(-scale, -scale, offset/2.0);
606 glVertex3f(-scale, -scale, -offset/2.0);
610 glVertex3f(-scale, scale-offset, -offset/2.0);
611 glVertex3f(-scale, scale-offset, offset/2.0);
612 glVertex3f(-scale, scale, offset/2.0);
613 glVertex3f(-scale, scale, -offset/2.0);
617 glVertex3f(-scale, -offset/2.0, -scale+offset);
618 glVertex3f(-scale, offset/2.0, -scale+offset);
619 glVertex3f(-scale, offset/2.0, -scale);
620 glVertex3f(-scale, -offset/2.0, -scale);
624 glVertex3f(-scale, -offset/2.0, scale-offset);
625 glVertex3f(-scale, offset/2.0, scale-offset);
626 glVertex3f(-scale, offset/2.0, scale);
627 glVertex3f(-scale, -offset/2.0, scale);
632 glVertex3f(scale, -scale+offset, -offset/2.0);
633 glVertex3f(scale, -scale+offset, offset/2.0);
634 glVertex3f(scale, -scale, offset/2.0);
635 glVertex3f(scale, -scale, -offset/2.0);
639 glVertex3f(scale, scale-offset, -offset/2.0);
640 glVertex3f(scale, scale-offset, offset/2.0);
641 glVertex3f(scale, scale, offset/2.0);
642 glVertex3f(scale, scale, -offset/2.0);
646 glVertex3f(scale, -offset/2.0, -scale+offset);
647 glVertex3f(scale, offset/2.0, -scale+offset);
648 glVertex3f(scale, offset/2.0, -scale);
649 glVertex3f(scale, -offset/2.0, -scale);
653 glVertex3f(scale, -offset/2.0, scale-offset);
654 glVertex3f(scale, offset/2.0, scale-offset);
655 glVertex3f(scale, offset/2.0, scale);
656 glVertex3f(scale, -offset/2.0, scale);
661 glVertex3f(-offset/2.0, -scale+offset, -scale);
662 glVertex3f(offset/2.0, -scale+offset, -scale);
663 glVertex3f(offset/2.0, -scale, -scale);
664 glVertex3f(-offset/2.0, -scale, -scale);
668 glVertex3f(-offset/2.0, scale-offset, -scale);
669 glVertex3f(offset/2.0, scale-offset, -scale);
670 glVertex3f(offset/2.0, scale, -scale);
671 glVertex3f(-offset/2.0, scale, -scale);
675 glVertex3f(-scale+offset, -offset/2.0, -scale);
676 glVertex3f(-scale+offset, offset/2.0, -scale);
677 glVertex3f(-scale, offset/2.0, -scale);
678 glVertex3f(-scale, -offset/2.0, -scale);
682 glVertex3f(scale-offset, -offset/2.0, -scale);
683 glVertex3f(scale-offset, offset/2.0, -scale);
684 glVertex3f(scale, offset/2.0, -scale);
685 glVertex3f(scale, -offset/2.0, -scale);
691 glVertex3f(-offset/2.0, -scale+offset, scale);
692 glVertex3f(offset/2.0, -scale+offset, scale);
693 glVertex3f(offset/2.0, -scale, scale);
694 glVertex3f(-offset/2.0, -scale, scale);
698 glVertex3f(-offset/2.0, scale-offset, scale);
699 glVertex3f(offset/2.0, scale-offset, scale);
700 glVertex3f(offset/2.0, scale, scale);
701 glVertex3f(-offset/2.0, scale, scale);
705 glVertex3f(-scale+offset, -offset/2.0, scale);
706 glVertex3f(-scale+offset, offset/2.0, scale);
707 glVertex3f(-scale, offset/2.0, scale);
708 glVertex3f(-scale, -offset/2.0, scale);
712 glVertex3f(scale-offset, -offset/2.0, scale);
713 glVertex3f(scale-offset, offset/2.0, scale);
714 glVertex3f(scale, offset/2.0, scale);
715 glVertex3f(scale, -offset/2.0, scale);
734 int cubes_first[12] = { 0, 1, 0, 2, 0, 3, 0, 1, 1, 2, 3, 4};
735 int cubes_second[12] = { 1, 2, 2, 3, 3, 4, 4, 4, 5, 5, 5, 5};
741 glColor3f(0.0, 0.0, 0.0);
746 theColor = cubes_first[cube];
748 theColor = cubes_second[cube];
752 case 0: glColor3f(1.0, 0.0, 0.0);
break;
753 case 1: glColor3f(0.0, 1.0, 0.0);
break;
754 case 2: glColor3f(0.0, 0.0, 1.0);
break;
755 case 3: glColor3f(1.0, 1.0, 0.0);
break;
756 case 4: glColor3f(1.0, 0.75, 0.0);
break;
757 case 5: glColor3f(1.0, 1.0, 1.0);
break;
758 default: assert(
false);