/* THIS IS THE CLUSTER VERSION OF THE PROGRAM DESCRIBED BELOW. * IT IS INTENDED TO RUN UNTIL IT IS SHUT DOWN. * This program determines the probabilities of each 2x2 game arising when games are generated by * randomly generating each payoff independently and as to total number of values that may be selected * for the payoffs increases. The program starts by considering 4 possible payoffs and then continues * until the total number of payoffs specified by the variable totalPayoffValues has been reached. * * The point of this is to determine the probability distribution of games generated in this way as the * number of possible values the payoffs can take approaches infinity. This result will be used to support * the following conjecture: [need to formulate] * * Pieces of this program were adapted from GameNumbers5. * * Pieces of the terminal output can be copied into text files and used to number games in other programs. * The output file that is created is intended to be loaded easily into MatLab or a similar program * that can easily do curve plotting and fitting. * * This work is licensed under the Creative Commons Attribution-Share Alike 2.5 Canada License. * This To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/2.5/ca/ * This or send a letter to Creative Commons, 171 Second Street, Suite 300, San Francisco, * This California, 94105, USA. * * Written by John Simpson, Department of Philosophy, University of Alberta, 2009, 2010. * */ //Need to test that the game ordering created here is the same as in the SR6 family of programs #include #include #include #include #include #include using namespace std; void headsUp (vector*); void swapDias(vector*); void swapCols(vector*); void swapRows(vector*); void swapPlayers(vector*); void printGame(vector*); void gameIndexer(vector*); int main(void) { int totalPayoffValues=50; //Must be greater than 4 int tempNumber=0; long double totalGames=0; string outFileName="gameProbabilities.ssv"; ofstream outFile0(outFileName.data(), ios::out); outFile0 << setprecision( 20 ); vector currentGame; //holds the 8 payoffs that make-up the game currently being considered vector gameNumbers; //holds the the lowest calculated ID number of every single game vector gameProbs (726, 0); //Stores the probability of each game occurring for each possible number of payoffs. vector > perspectives; vector gameIndexNumbers; gameIndexer(&gameIndexNumbers); for (int payoffLoopCount=22; payoffLoopCount* currentGamePtr) { vector vPays(*currentGamePtr); //cout << "Pre Ordinality" << endl; //printGame(&vPays); //Game is converted to its minimum ordinal form. First for Row and then for Column. vector ordPays; for (int h=0; h<2; h++) //h=0 ROW, h=1 COLUMN { for (int i=0; i<4; i++) //Looks at four given outcome associated payoffs for the player (row/column) if (count(ordPays.begin(), ordPays.end(), vPays.at(i+(h*4)))==0) //if ordPays doesn't have the next value already then add it ordPays.push_back(vPays.at(i+(h*4))); sort(ordPays.begin(), ordPays.end()); //Orders the payoffs the player is currently receiving from smallest to largest for (int i=0; i permValues; permValues.push_back(((vPays.at(0)+vPays.at(4)*4)+ (vPays.at(2)+vPays.at(5)*4)*16)+ ((vPays.at(1)+vPays.at(6)*4)+ (vPays.at(3)+vPays.at(7)*4)*16)*256); permValues.push_back(((vPays.at(1)+vPays.at(6)*4)+ (vPays.at(3)+vPays.at(7)*4)*16)+ ((vPays.at(0)+vPays.at(4)*4)+ (vPays.at(2)+vPays.at(5)*4)*16)*256); permValues.push_back(((vPays.at(2)+vPays.at(5)*4)+ (vPays.at(0)+vPays.at(4)*4)*16)+ ((vPays.at(3)+vPays.at(7)*4)+ (vPays.at(1)+vPays.at(6)*4)*16)*256); permValues.push_back(((vPays.at(3)+vPays.at(7)*4)+ (vPays.at(1)+vPays.at(6)*4)*16)+ ((vPays.at(2)+vPays.at(5)*4)+ (vPays.at(0)+vPays.at(4)*4)*16)*256); /*Uncommenting returns to base 726 games vs. extended perspective of non-symmetric games*/ permValues.push_back(((vPays.at(4)+vPays.at(0)*4)+ (vPays.at(6)+vPays.at(1)*4)*16)+ ((vPays.at(5)+vPays.at(2)*4)+ (vPays.at(7)+vPays.at(3)*4)*16)*256); permValues.push_back(((vPays.at(5)+vPays.at(2)*4)+ (vPays.at(7)+vPays.at(3)*4)*16)+ ((vPays.at(4)+vPays.at(0)*4)+ (vPays.at(6)+vPays.at(1)*4)*16)*256); permValues.push_back(((vPays.at(6)+vPays.at(1)*4)+ (vPays.at(4)+vPays.at(0)*4)*16)+ ((vPays.at(7)+vPays.at(3)*4)+ (vPays.at(5)+vPays.at(2)*4)*16)*256); permValues.push_back(((vPays.at(7)+vPays.at(3)*4)+ (vPays.at(5)+vPays.at(2)*4)*16)+ ((vPays.at(6)+vPays.at(1)*4)+ (vPays.at(4)+vPays.at(0)*4)*16)*256); /**/ int minMut=0; int minMutLoc=0; minMut=*(min_element(permValues.begin(), permValues.end())); while (minMut!=permValues.at(minMutLoc)) minMutLoc++; switch (minMutLoc) { case 0: break; case 1: swapRows(&vPays); break; case 2: swapCols(&vPays); break; case 3: swapDias(&vPays); break; case 4: swapPlayers(&vPays); break; case 5: swapPlayers(&vPays); swapRows(&vPays); break; case 6: swapPlayers(&vPays); swapCols(&vPays); break; case 7: swapPlayers(&vPays); swapDias(&vPays); break; default: cout << "ERROR " << minMutLoc << endl; break; } currentGamePtr->clear(); *currentGamePtr = vPays; } void swapDias(vector* vPaysPtr) { swap (vPaysPtr->at(0), vPaysPtr->at(3)); swap (vPaysPtr->at(1), vPaysPtr->at(2)); swap (vPaysPtr->at(4), vPaysPtr->at(7)); swap (vPaysPtr->at(5), vPaysPtr->at(6)); } void swapCols(vector* vPaysPtr) { swap (vPaysPtr->at(0), vPaysPtr->at(2)); swap (vPaysPtr->at(1), vPaysPtr->at(3)); swap (vPaysPtr->at(4), vPaysPtr->at(5)); swap (vPaysPtr->at(6), vPaysPtr->at(7)); } void swapRows(vector* vPaysPtr) { swap (vPaysPtr->at(0), vPaysPtr->at(1)); swap (vPaysPtr->at(2), vPaysPtr->at(3)); swap (vPaysPtr->at(4), vPaysPtr->at(6)); swap (vPaysPtr->at(5), vPaysPtr->at(7)); } void swapPlayers(vector* vPaysPtr) { swap_ranges (vPaysPtr->begin(), vPaysPtr->begin() + 4, vPaysPtr->begin() + 4); } void printGame(vector* vPaysPtr) { cout << vPaysPtr->at(0) << " " << vPaysPtr->at(4) << " " << "|" << " " << vPaysPtr->at(2) << " " << vPaysPtr->at(5) << " " << endl; cout << "----------------" << endl; cout << vPaysPtr->at(1) << " " << vPaysPtr->at(6) << " " << "|" << " " << vPaysPtr->at(3) << " " << vPaysPtr->at(7) << " " << endl; cout << endl << endl; } void gameIndexer (vector* gameIndexNumbersPtr) { vector currentGame; //holds the 8 payoffs that make-up the game currently being considered int tempNumber=0; for (int i=0; i<4; i++) //0 for (int j=0; j<4; j++) //1 for (int k=0; k<4; k++) //2 for (int l=0; l<4; l++) //3 for (int m=0; m<4; m++) //4 for (int n=0; n<4; n++) //5 for (int p=0; p<4; p++) //6 for (int q=0; q<4; q++) //7 { currentGame.push_back(i); currentGame.push_back(j); currentGame.push_back(k); currentGame.push_back(l); currentGame.push_back(m); currentGame.push_back(n); currentGame.push_back(p); currentGame.push_back(q); headsUp(¤tGame); //put the index "score" of the current game into a temporary variable for easy future reference tempNumber=((currentGame.at(0)+currentGame.at(4)*4)+ (currentGame.at(2)+currentGame.at(5)*4)*16)+ ((currentGame.at(1)+currentGame.at(6)*4)+ (currentGame.at(3)+currentGame.at(7)*4)*16)*256; if (count(gameIndexNumbersPtr->begin(),gameIndexNumbersPtr->end(),tempNumber)==0) gameIndexNumbersPtr->push_back(tempNumber); currentGame.clear(); } //sort(gameIndexNumbersPtr->begin(),gameIndexNumbersPtr->end()); }