const char* pieceTypes[] = {
"0 1 .", //0
"0 2 .", //1
"0 3 .", //2
"0 1 2 .", //3
"0 1 3 .", //4
"0 1 4 .", //5
"0 1 2 3 .", //6
"0 1 2 4 .", //7
"0 1 3 4 .", //8
"0 1 ; 2 3 .", //9
"0 1 2 3 4 .", //10
"0 1 2 3 4 5 .", //11
"0 1 ; 2 3 ; 4 5 ." //12
};
static int numberOfTitles(int radius){
return 3 * (radius * radius + radius);
}
class PipesCase : public TestCase {
public:
PipesCase(){};
PipesCase(int r){radius = r;};
void addTitle(int t){ titles.push_back(pieceTypes[t]);}
void randomize(){
random_shuffle(titles.begin(), titles.end());
}
string toString(){
stringstream ss;
randomize();
ss << radius << endl;
for (vector<const char*>::iterator it = titles.begin(); it != titles.end(); it++){
ss << *it << endl;
}
ss << endl;
return ss.str();
}
private:
vector<const char*> titles;
int radius;
};
PipesCase* trulyRandomCase(int radius){
PipesCase* myCase = new PipesCase(radius);
for (int i=0; i < numberOfTitles(radius); i++) myCase->addTitle(rand()%13);
return myCase;
}
PipesCase* sparseRandomCase(int radius){
PipesCase* myCase = new PipesCase(radius);
for (int i=0; i < numberOfTitles(radius); i++){
if (i%3 != 0) myCase->addTitle(rand()%6); // 2/3 of the pieces are from range 0-5
else myCase->addTitle(rand()%13);
}
return myCase;
}
PipesCase* denseRandomCase(int radius){
PipesCase* myCase = new PipesCase(radius);
for (int i=0; i < numberOfTitles(radius); i++){
if (i%3 != 0) myCase->addTitle(rand()%6 + 6); // 2/3 of the pieces are from range 6 - 11
else myCase->addTitle(rand()%13);
}
return myCase;
}
PipesCase* disjointRandomCase(int radius){
PipesCase* myCase = new PipesCase(radius);
for (int i=0; i < numberOfTitles(radius); i++){
if (i%3 == 0) myCase->addTitle(9); // 1/3 of the pieces are type 9
else if (i%3 == 1) myCase->addTitle(12); //and 1/3 is of type 12
else myCase->addTitle(rand()%13);
}
return myCase;
}
void randomCases(TestSet &cases){
for (int i = 1; i <= 19; i += 6){
cases.addTestCase(trulyRandomCase(i));
cases.addTestCase(sparseRandomCase(i));
cases.addTestCase(denseRandomCase(i));
cases.addTestCase(disjointRandomCase(i));
}
}
void bigRandomCases(TestSet &cases){
cases.addTestCase(sparseRandomCase(25));
cases.addTestCase(disjointRandomCase(25));
}