/*************************************************************************** main.cpp - description ------------------- begin : Die Feb 19 12:20:21 CET 2002 copyright : (C) 2002 by Sven Klauke email : sklauke@wiwi.uni-bielefeld.de Institute of Mathematical Economics (IMW) University of Bielefeld, Germany http://www.wiwi.uni-bielefeld.de/~imw/ I ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ // Modified by Alex Kontorovich & John F. Nash Jr. 6/11/2002 #include #include #include #include "game.h" #include "rand.h" #include "nuk.h" #include "sort.h" #include "calc.h" int main () { int *ko; double x_s,v_s; int i,j,maxe; double maxw,h; char result_file[80]; char game_file[80]; char precisPrint[80]; double precision=0.0; double *excess; double *nucleolus; float temp; FILE *file; zufall_ini (); // sets randomizer seed // Inputs name of game and precision of calculation printf("Please enter the number of players in this game: "); scanf("%d",&n); coalitions=(int)(pow(2,n)); printf("\nPlease enter the desired precision of the calculation (number of decimal places): "); scanf("%d",&PRECISION); precision=1.0/(pow(10,PRECISION)); sprintf(precisPrint,"%%1.%df ",PRECISION+1); printf("\nPlease enter the exact file name which contains coalition values. Format should be:\n"); for(i=0;i maxw) { maxw = excess[j]; maxe = j; } } h = excess[i]; excess[i] = excess[maxe]; excess[maxe] = h; h = ko[i]; ko[i] = ko[maxe]; ko[maxe] = (int) h; } // and print the results sprintf(result_file,"result_%s",game_file); file=fopen(result_file,"w"); printf("The Prenucleolus (Prescision=%d places): \n\n",PRECISION); fprintf(file,"The Prenucleolus (Prescision=%d places): \n\n",PRECISION); for (i = 0;i < n; i++) { printf("x%d = ",i+1); printf(precisPrint,nucleolus[i]); printf("\n"); fprintf(file,"x%d = ",i+1); fprintf(file,precisPrint,nucleolus[i]); fprintf(file,"\n"); } fprintf(file,"\nExcesses:\n\n"); for(i=0;i