17 uint64_t val = (1ull<<which);
23 uint64_t val = (1ull<<which);
29 uint64_t val = (1ull<<which);
35 uint64_t val = (1ull<<which);
41 uint64_t val = (1ull<<which);
47 uint64_t val = (1ull<<which);
53 uint64_t val = (1ull<<offset);
59 uint64_t val = (1ull<<(y*
width+x));
65 uint64_t val = (1ull<<offset);
71 uint64_t val = (1ull<<(y*
width+x));
77 uint64_t val = (1ull<<offset);
83 uint64_t val = (1ull<<(y*
width+x));
98 std::sort(
locs.begin(),
locs.end(), std::greater<std::pair<int,int>>());
111 std::sort(
locs.begin(),
locs.end(), std::greater<std::pair<int,int>>());
127 if (
locs[x].first == offset)
132 std::sort(
locs.begin(),
locs.end(), std::greater<std::pair<int,int>>());
140 int xx = which%
width;
141 int yy = which/
width;
146 while ((xx >= 0) && (xx <
width) && (yy >= 0) && (yy <
height))
163 for (
size_t i = 0; i <
locs.size(); i++)
165 if (
locs[i].first == offset)
170 assert(!
"Didn't find index of location!");
181 int xx = which%
width;
182 int yy = which/
width;
189 while ((xx >= 0) && (xx <
width) && (yy >= 0) && (yy <
height))
204 std::sort(
locs.begin(),
locs.end(), std::greater<std::pair<int,int>>());
220 std::sort(
locs.begin(),
locs.end(), std::greater<std::pair<int,int>>());
236 case kRight: x = 1; y = 0;
break;
237 case kLeft: x = -1; y = 0;
break;
238 case kUp: x = 0; y = -1;
break;
239 case kDown: x = 0; y = 1;
break;
245 while ((xx >= 0) && (xx <
width) && (yy >= 0) && (yy <
height))
250 return lasty*
width+lastx;
256 assert(!
"No collision found for piece");
265 for (
size_t x = 0; x < in.
width; x++)
267 for (
size_t y = 0; y < in.
height; y++)
289 for (
size_t x = 0; x < in.
width; x++)
300 for (
size_t y = 1; y < in.
height; y++)
302 for (
size_t x = 0; x < in.
width; x++)
314 for (
size_t y = 0; y < in.
height; y++)
322 for (
size_t x = 1; x < in.
width; x++)
324 for (
size_t y = 0; y < in.
height; y++)
403 return (
node.locs.size() == 1);
410 for (
unsigned int x = 0; x < nodeID.
locs.size(); x++)
416 neighbors.push_back(b);
421 b.
Move(nodeID.
locs[x].first, -1, 0);
422 neighbors.push_back(b);
428 neighbors.push_back(b);
433 b.
Move(nodeID.
locs[x].first, 0, -1);
434 neighbors.push_back(b);
443 for (
size_t x = 0; x < nodeID.
locs.size(); x++)
449 actions.push_back(m);
455 actions.push_back(m);
461 actions.push_back(m);
467 actions.push_back(m);
510 std::vector<FlingMove> m1;
515 for (
int x = 0; x < m1.size(); x++)
525 assert(found ==
true);
533 bool onBoard =
false;
534 for (
unsigned int x = 0; x <
node.locs.size(); x++)
536 hash |= (1ull<<
node.locs[x].first);
555 if (1 == ((parent>>x)&0x1))
571 double diameter = radius*2;
572 double xLoc = -1+radius;
573 double yLoc = -1+radius;
575 glColor3f(0.0, 0.0, 0.5);
577 glVertex3f(-1+diameter, -1+diameter, 0);
578 glVertex3f(-1+diameter, -1+(diameter*b.
height)+diameter, 0);
579 glVertex3f(-1+diameter*(b.
width)+diameter, -1+diameter*(b.
height)+diameter, 0);
580 glVertex3f(-1+diameter*(b.
width)+diameter, -1+diameter, 0);
584 glColor3f(1.0, 1.0, 1.0);
586 for (
double x = 0; x <= b.
width; x++)
588 glVertex3f(-1+(x+1)*diameter, -1+diameter, 0);
589 glVertex3f(-1+(x+1)*diameter, -1+diameter*b.
height+diameter, -0.01);
592 for (
double y = 0; y <= b.
height; y++)
595 glVertex3f(-1+diameter, -1+(y+1)*diameter, 0);
596 glVertex3f(-1+diameter*b.
width+diameter, -1+(y+1)*diameter, -0.01);
602 for (
double x = 0; x < b.
width; x++)
606 for (
double y = 0; y < b.
height; y++)
612 glColor3f(r.
r, r.
g, r.
b);
618 DrawBox(xLoc, yLoc, 0, radius);
623 DrawBox(xLoc, yLoc, 0, radius);
632 double diameter = radius*2;
635 double r = radius*0.85;
637 glColor3f(1.0, 1.0, 1.0);
639 glVertex3f(-2, -2, 0);
640 glVertex3f(-2, +2, 0);
641 glVertex3f(+2, +2, 0);
642 glVertex3f(+2, -2, 0);
664 glDisable(GL_LIGHTING);
666 glColor4f(0.0, 0.0, 0.0, 1.0);
668 for (
double x = 0; x < b.
width; x++)
672 for (
double y = 0; y < b.
height; y++)
680 glVertex3f(xLoc-r, yLoc-r-r, -0.02);
681 glVertex3f(xLoc-r, yLoc+r-r, -0.02);
682 glVertex3f(xLoc+r, yLoc+r-r, -0.02);
683 glVertex3f(xLoc+r, yLoc-r-r, -0.02);
690 glEnable(GL_LIGHTING);
697 double diameter = radius*2;
698 double xLoc = -1+radius;
700 double r = radius*0.80;
702 glDisable(GL_LIGHTING);
704 glColor4f(0.0, 0.5, 0.0, 1.0);
706 for (
double x = 0; x < b.
width; x++)
710 for (
double y = 0; y < b.
height; y++)
718 glVertex3f(xLoc-r, yLoc-r, -0.02);
719 glVertex3f(xLoc-r, yLoc+r, -0.02);
720 glVertex3f(xLoc+r, yLoc+r, -0.02);
721 glVertex3f(xLoc+r, yLoc-r, -0.02);
728 glEnable(GL_LIGHTING);
735 double diameter = radius*2;
736 double xLoc = -1+radius+diameter;
737 double yLoc = -1+radius+diameter;
739 glColor3f(1.0, 1.0, 1.0);
741 glBegin(GL_TRIANGLES);
750 glVertex3f(xLoc+x*diameter, yLoc+y*diameter-radius/2, -radius);
751 glVertex3f(xLoc+x*diameter, yLoc+y*diameter+radius/2, -radius);
752 glVertex3f(xLoc+x*diameter-radius, yLoc+y*diameter, -radius);
755 glVertex3f(xLoc+x*diameter, yLoc+y*diameter+radius/2, -radius);
756 glVertex3f(xLoc+x*diameter, yLoc+y*diameter-radius/2, -radius);
757 glVertex3f(xLoc+x*diameter+radius, yLoc+y*diameter, -radius);
760 glVertex3f(xLoc+x*diameter+radius/2, yLoc+y*diameter, -radius);
761 glVertex3f(xLoc+x*diameter-radius/2, yLoc+y*diameter, -radius);
762 glVertex3f(xLoc+x*diameter, yLoc+y*diameter-radius, -radius);
765 glVertex3f(xLoc+x*diameter-radius/2, yLoc+y*diameter, -radius);
766 glVertex3f(xLoc+x*diameter+radius/2, yLoc+y*diameter, -radius);
767 glVertex3f(xLoc+x*diameter, yLoc+y*diameter+radius, -radius);
777 double diameter = radius*2;
786 if (x >= 0 && x < b.width && y >= 0 && y < b.
height)
793 glDisable(GL_LIGHTING);
794 glEnable(GL_LINE_SMOOTH);
795 glDisable(GL_DEPTH_TEST);
799 double diameter = radius*2;
800 double xLoc = -1+radius;
803 for (
double x = 0; x < b.
width; x++)
807 for (
double y = 0; y < b.
height; y++)
810 glColor3f(1.0, 1.0, 1.0);
816 glTranslatef(xLoc-radius+1/152.38, yLoc-radius+8/152.38, 0);
817 glScalef(.05/152.38, -.05/152.38, .05/152.38);
818 glTranslatef(0, 0, -2*radius);
822 for (p = text; *p; p++)
843 glEnable(GL_DEPTH_TEST);
844 glEnable(GL_LIGHTING);
845 glDisable(GL_LINE_SMOOTH);
858 int newPieceLocation;
865 newPieceLocation = currPieceLocation+1;
869 b.
locs[piece].first = newPieceLocation;
870 return newPieceLocation;
886 int NUM_SPOTS = spots;
895 value =
binomial(NUM_SPOTS-(NUM_PIECES-2) - i - 1, ls - 1);
900 if (firstIndex < value)
908 return binomial(NUM_SPOTS-i,NUM_PIECES-2);
914 int NUM_PIECES = (int)s.
locs.size();
917 int last = NUM_SPOTS-1;
918 for (
int x = 0; x < NUM_PIECES; x++)
920 int64_t tmp =
binomialSum(last, NUM_SPOTS-s.
locs[NUM_PIECES-1-x].first-1, NUM_PIECES-1-x);
922 last = NUM_SPOTS-s.
locs[NUM_PIECES-1-x].first-1-1;
930 int NUM_PIECES = (int)s.
locs.size();
932 int tot = NUM_SPOTS-1-(NUM_PIECES-2);
934 for (
int x = 0; x < 2; x++)
936 int64_t tmp =
binomialSum(last, tot-s.
locs[NUM_PIECES-1-x].first, (2)-1-x);
938 last = tot-s.
locs[NUM_PIECES-1-x].first-1;
942 last = NUM_SPOTS-s.
locs[NUM_PIECES-1-1].first-1-1;
943 for (
int x = 2; x < NUM_PIECES; x++)
945 int64_t tmp =
binomialSum(last, NUM_SPOTS-s.
locs[NUM_PIECES-1-x].first-1, NUM_PIECES-1-x);
947 last = NUM_SPOTS-s.
locs[NUM_PIECES-1-x].first-1-1;
954 int NUM_PIECES = (int)s.
locs.size();
957 int tot = NUM_SPOTS-1-(NUM_PIECES-2);
959 for (
int x = 0; x < 2; x++)
961 int64_t tmp =
binomialSum(last, tot-s.
locs[NUM_PIECES-1-x].first, (2)-1-x);
963 last = tot-s.
locs[NUM_PIECES-1-x].first-1;
970 int NUM_PIECES = (int)s.
locs.size();
974 last = NUM_SPOTS-s.
locs[NUM_PIECES-1-1].first-1-1;
975 for (
int x = 2; x < NUM_PIECES; x++)
977 int64_t tmp =
binomialSum(last, NUM_SPOTS-s.
locs[NUM_PIECES-1-x].first-1, NUM_PIECES-1-x);
979 last = NUM_SPOTS-s.
locs[NUM_PIECES-1-x].first-1-1;
991 unsigned int ls = NUM_PIECES;
995 for (
int i=0; ls > 0; ++i)
1000 value =
binomial(NUM_SPOTS - i - 1, ls - 1);
1005 if (theRank < value)
1009 s.
locs[ls-1].first = i;
1010 s.
locs[ls-1].second = ls-1;
1019 for (
int x = 1; x < NUM_PIECES; x++)
1051 for (
int x = n1; x > n2; x--)
1064 for (
int x = 0; x <= 56; x++)
1083 const unsigned int bound = (n - k);