#include "VegaMain.h" #include "Tournament.h" void RoundData::ShowTableStat() // // PURPOSE: show statistics information about tournament // { int j; float sum=0., sumfide=0.; String stringa, str, countrylist[N_PLAYER_MAX+1]; int idopp, ctitle[6], titopp=0, ratopp=0; int playernothostfed=0, titoppnothost=0; int playerhostfed=0, countcountry=0, l, found; extern int roundfloat( double per); FileOut save (PATHDIR + "tourstat.txt"); save<< "\n Tournament Name: " << NAMETORNEO << "\n"; save<< " Place: " << PLACETORNEO << "\n"; save<< " Federation: " << HOSTFEDERATION << "\n"; save<< " Date: " << DATATORNEO_B <<", "<0) { ratopp++; //numfideplayers sumfide += player[j].ratingfide; //BUG fixed (not yet in 4.2.7 } if (player[idopp].title>=10) titopp++; if (player[idopp].title>=10 && player[idopp].country != HOSTFEDERATION) titoppnothost++; switch (player[idopp].title) { case 20: ctitle[0]++; break; case 16: ctitle[1]++; break; case 18: ctitle[2]++; break; case 14: ctitle[3]++; break; case 12: ctitle[4]++; break; case 11: ctitle[5]++; break; } // count federations l=0; found=0; while (l<=countcountry && !found) { if ( player[idopp].country == countrylist[l]) { found = 1; break; } else l++; } if (!found) { countcountry++; countrylist[countcountry] = player[idopp].country; } } save<< "\n"; save<< " Registered Players: " << NPlayer << "\n"; save<< " Number of Federations: " << countcountry << "\n"; save<< " Average Rating (all): " << roundfloat(sum/NPlayer) << "\n"; if (ratopp>0) save<< " Average Rating (only FIDE rated): " << roundfloat(sumfide/ratopp) << "\n"; else save<< " Average Rating (only FIDE rated): " << 0 << "\n"; save<< " Players from "<" << "Tournament summary" << "\n"; save << " \n"; save << "\n"; save<< "\n"; save<< "\n"; save<< "\n"; save<< "\n"; save<< "\n"; save<< "\n"; if (PLAY_SYSTEM== DUBOV) str = "swiss FIDE (Dubov)\n"; else if (PLAY_SYSTEM== ROUND_ROBIN) str = "Single Round Robin\n"; else if (PLAY_SYSTEM == ROUND_ROBIN2) str = "Double Round Robin\n"; else if (PLAY_SYSTEM== VEGA) str = "swiss vega\n"; else if (PLAY_SYSTEM== USCF) str = "swiss USCF\n"; else if (PLAY_SYSTEM== LIM) str = "swiss FIDE (Lim)\n"; save<< "\n"; save<< "\n"; save<< "\n"; save<< "\n"; // count titled and rated player and calculate their aro for(j=0; j<=5; j++) ctitle[j]=0; for (j=1; j<=NPlayer; j++) { idopp = j; sum += player[j].ratingnat; //BUG fixed (not yet in 4.2.7 if ( player[idopp].country == HOSTFEDERATION || player[idopp].country.GetLength() < 3 // hanno inserito una provincia o uno stato ) playerhostfed++; // if ( player[idopp].country == HOSTFEDERATION) playerhostfed++; else playernothostfed++; if (player[j].ratingfide>0) { ratopp++; sumfide += player[j].ratingfide; //BUG fixed (not yet in 4.2.7 } if (player[idopp].title>=10) titopp++; if (player[idopp].title>=10 && player[idopp].country != HOSTFEDERATION) titoppnothost++; switch (player[idopp].title) { case 20: ctitle[0]++; break; case 16: ctitle[1]++; break; case 18: ctitle[2]++; break; case 14: ctitle[3]++; break; case 12: ctitle[4]++; break; case 11: ctitle[5]++; break; } // count federations l=0; found=0; while (l<=countcountry && !found) { if ( player[idopp].country == countrylist[l]) { found = 1; break; } else l++; } if (!found) { countcountry++; countrylist[countcountry] = player[idopp].country; } } save<< "\n"; save<< "\n"; save<< "\n"; if (ratopp>0) save<< "\n"; else save<< "\n"; save<< "\n"; save<< "\n"; save<< "\n"; save<< "\n"; save<< "\n"; save<< "\n"; save<< "\n"; save<< "\n"; save<< "\n"; save<< "\n"; save<< "\n"; save<< "\n"; save<< "\n"; save<< "\n"; save << "\n"; save << "
Tournament Name " << NAMETORNEO << "
Place " << PLACETORNEO << "
Federation " << HOSTFEDERATION << "
Date Begin " << DATATORNEO_B << "
Date End " << DATATORNEO_E << "
Arbiter " << ARBITER << "
Play System " << str << "
Number of rounds " << NRounds << "
Score game 0-" << DRAW << "-" << WON << "
Tie break "; j=1; while (tyebreakorder[j]) { switch ( tyebreakorder[j] ) { case 1: save << tyebreakname[ tyebreakorder[j] ]; break; case 2: save << tyebreakname[ tyebreakorder[j] ]; break; case 3: save << tyebreakname[ tyebreakorder[j] ]; break; case 4: save << tyebreakname[ tyebreakorder[j] ]; break; case 5: save << tyebreakname[ tyebreakorder[j] ]; break; case 6: save << tyebreakname[ tyebreakorder[j] ]; break; case 7: save << tyebreakname[ tyebreakorder[j] ]; break; case 8: save << tyebreakname[ tyebreakorder[j] ]; break; case 9: save << tyebreakname[ tyebreakorder[j] ]; break; } j++; } save << "
Registered Players " << NPlayer << "
Number of Federations " << countcountry << "
Average Rating (all) " << roundfloat(sum/NPlayer) << "
Average Rating (only FIDE rated) " << roundfloat(sumfide/ratopp) << "
Average Rating (only FIDE rated) " << 0 << "
Players from "< " << playerhostfed << "
Players NOT from "< " << playernothostfed << "
FIDE rated players " << ratopp << "
FIDE unrated players " << NPlayer-ratopp << "
FIDE titled players " << titopp << "
GM players " << ctitle[0] << "
WGM players " << ctitle[2] << "
IM players " << ctitle[1] << "
WIM players " << ctitle[3] << "
FM players " << ctitle[4] << "
WFM players " << ctitle[5] << "
FIDE titled player from " < " << titopp-titoppnothost << "
FIDE titled player NOT from " < " << titoppnothost << "
IM players " << ctitle[1] << "
\n"; save << "

Generated by Vega

\n"; save << "\n\n"; save.Close(); } void RoundData::SortedCross(int nplayers, int flag) // // PURPOSE: sort the cross table according to the ranking // // INPUT VARIABLE // n = number of players to be sorted // // flag = 1 for score ID regenation, 0 according rating, title and name // { int i, k, j, id, index; int arr[N_PLAYER_MAX+1]; int id_to_pos[N_PLAYER_MAX+1]; String stringa, str; FileOut save (PATHDIR + "sortcros.txt"); int *roundRes; int *playerCol; int *playerOpp; extern int CompareScoreName(const void *pid1, const void *pid2); extern int CompareRatingTitleName( const void *pid1, const void *pid2); for (i=0; i 0 ) noppfide++; //nopp++; } } // elaboration if ( ((player[i].ratingfide>0) && (noppfide>0)) || ((player[i].ratingfide==0) && (noppfide>=3)) ) { calcelo(i, arrp, currentRound); for(j=1; j<=currentRound; j++) { if (IS_SWISS) index = i*(N_ROUND_MAX+1) + j; else index = i*(N_ROUND_MAX_RR+1) + j; idopp = playerOpp[index]; if ( idopp!=0 && (player[idopp].ratingfide>0) && (roundRes[index]<3) ) { // not forfait totexp += arrp[j][1]; //if (player[idopp].ratingfide>0) arofide += player[idopp].ratingfide; arofide += player[idopp].ratingfide; if (roundRes[index]==1) { //if (player[idopp].ratingfide>0) { totscorefide += 1.0; //} totscore += 1.0; result = 1.; } else if (roundRes[index]==2) { //if (player[idopp].ratingfide>0) { totscorefide += 0.5; //} totscore += 0.5; result = 0.5; // } else result = 0.; } } if (noppfide>0) arofide = arofide/noppfide; else arofide = 0.; if (player[i].ratingfide>0) we_w = totscorefide - totexp; else we_w = 0.; if (player[i].ratingfide==0 && totscorefide/noppfide<=0.5) rp = roundfloat (arofide + p_dp[ roundfloat(100.* totscorefide /noppfide) ] ); else if (player[i].ratingfide==0 && totscorefide/noppfide>0.5) rp = roundfloat ( arofide + 25*(totscorefide-noppfide/2.) ); else rp = roundfloat(arofide + p_dp[ roundfloat(100.* totscorefide /noppfide) ] ); save << NFormat(" %3d %3s %-20.20s %8d %3s %4d ", i, player[i].codetitle, player[i].name, player[i].idfide, player[i].country, player[i].ratingfide); save << NFormat("%2d %4.1f %4d %5.2f %4d\n", noppfide, totscorefide, roundfloat(arofide), we_w, rp); } } save<<"\n Generated by Vega - www.vegachess.com\n"; save.Close(); } void RoundData::FideEloVariationHTML() { int i, j, idopp, noppfide, index, rp; String stringa; double tot, totscore, totscorefide, we_w, result, arofide, totexp; double arrp[N_ROUND_MAX_RR+2][2]; int *roundRes; int *playerOpp; extern int p_dp[]; extern int roundfloat( double per); FileOut savehtml(PATHDIRWWW + "felovar.html"); savehtml << TD.HTMLCommonHeader(); savehtml << HTMLNavBar(); savehtml << "

" << NAMETORNEO << "

\n"; savehtml << "

" << PLACETORNEO << " - " << DATATORNEO_B <<", "<\n"; savehtml << "

Rating variation at round "<< currentRound<< "

\n"; savehtml << " \n"; savehtml << "\n"; savehtml << ""; if (IS_SWISS) { playerOpp = &playerOpponent[0][0]; roundRes = &roundResult[0][0]; } else { playerOpp = &playerOpponentRR[0][0]; roundRes = &roundResultRR[0][0]; } for (i=1; i<=NPlayer; i++) { tot = totexp = 0.; arofide = 0.; noppfide = 0; totscore = totscorefide = 0.; //score without to consider the forfait // preliminary test to calculate noppfide (only fide opponent) for(j=1; j<=currentRound; j++) { if (PLAY_SYSTEM != ROUND_ROBIN && PLAY_SYSTEM != ROUND_ROBIN2) index = i*(N_ROUND_MAX+1) + j; else index = i*(N_ROUND_MAX_RR+1) + j; idopp = playerOpp[index]; if ( idopp!=0 && (roundRes[index]<3) ) { // not forfait if (player[idopp].ratingfide > 0 ) noppfide++; //nopp++; } } // elaboration if ( ((player[i].ratingfide>0) && (noppfide>0)) || ((player[i].ratingfide==0) && (noppfide>=3)) ) { calcelo(i, arrp, currentRound); for(j=1; j<=currentRound; j++) { if (IS_SWISS) index = i*(N_ROUND_MAX+1) + j; else index = i*(N_ROUND_MAX_RR+1) + j; idopp = playerOpp[index]; if ( idopp!=0 && (player[idopp].ratingfide>0) && (roundRes[index]<3) ) { // not forfait totexp += arrp[j][1]; arofide += player[idopp].ratingfide; if (roundRes[index]==1) { totscorefide += 1.0; totscore += 1.0; result = 1.; } else if (roundRes[index]==2) { totscorefide += 0.5; totscore += 0.5; result = 0.5; } else result = 0.; } } if (noppfide>0) arofide = arofide/noppfide; else arofide = 0.; if (player[i].ratingfide>0) we_w = totscorefide - totexp; else we_w = 0.; if (player[i].ratingfide==0 && totscorefide/noppfide<=0.5) rp = roundfloat (arofide + p_dp[ roundfloat(100.* totscorefide /noppfide) ] ); else if (player[i].ratingfide==0 && totscorefide/noppfide>0.5) rp = roundfloat ( arofide + 25*(totscorefide-noppfide/2.) ); else rp = roundfloat(arofide + p_dp[ roundfloat(100.* totscorefide /noppfide) ] ); stringa = NFormat("", i, player[i].codetitle, player[i].name, player[i].idfide, player[i].country, player[i].ratingfide); stringa << NFormat("", noppfide, totscorefide, roundfloat(arofide), we_w, rp); if (i&1) savehtml <<" "; else savehtml << " "; savehtml << stringa; savehtml << "\n"; } } savehtml << "\n"; savehtml << "
ID Cat NAME FIDE ID Fed Rat Ng Score ARO W-We Rp
%3d %3s %-20.20s %8d %3s %4d%2d %4.1f %4d %5.2f %4d
\n"; savehtml << "
Generated by Vega \n"; savehtml << "\n\n"; savehtml.Close(); } void RoundData::FidePlayerCard() { int i, j, idopp, noppfide, index; String stringa, color; double tot, totscore, totscorefide, result, arofide, totexp; double arrp[N_ROUND_MAX_RR+2][2]; int *roundRes; int *playerCol; int *playerOpp; extern int p_dp[]; extern int roundfloat( double per); FileOut save( PATHDIR + "fidecard.txt"); if (IS_SWISS) { playerOpp = &playerOpponent[0][0]; roundRes = &roundResult[0][0]; playerCol = &playerColor[0][0]; } else { playerOpp = &playerOpponentRR[0][0]; roundRes = &roundResultRR[0][0]; playerCol = &playerColorRR[0][0]; } for (i=1; i<=NPlayer; i++) { tot = totexp = 0.; arofide = 0.; noppfide = 0; totscore = totscorefide = 0.; //score without to consider the forfait // preliminary test to calculate and noppfide (only fide opponent) for(j=1; j<=currentRound; j++) { if (IS_SWISS) index = i*(N_ROUND_MAX+1) + j; else index = i*(N_ROUND_MAX_RR+1) + j; idopp = playerOpp[index]; if ( idopp!=0 && (roundRes[index]<3) ) { // not forfait if (player[idopp].ratingfide > 0 ) noppfide++; } } // elaboration if ( ((player[i].ratingfide>0) && (noppfide>0)) || ((player[i].ratingfide==0) && (noppfide>=3)) ) { save <<"\n Name: " << player[i].name << ", Startingrank-Number = " << i <<"\n"; save <<" Fide ID: " << player[i].idfide << ", Rating: " << player[i].ratingfide << ", Title: " << player[i].codetitle; save<< ", Birthdate: " << player[i].data << ", Fed: "<0) && (roundRes[index]<3) ) { // not forfait and fide player totexp += arrp[j][1]; // if (player[idopp].ratingfide>0) arofide += player[idopp].ratingfide; arofide += player[idopp].ratingfide; if (roundRes[index]==1) { //if (player[idopp].ratingfide>0) { totscorefide += 1.0; //} totscore += 1.0; result = 1.; } else if (roundRes[index]==2) { //if (player[idopp].ratingfide>0) { totscorefide += 0.5; //} totscore += 0.5; result = 0.5; } else result = 0.; if (playerCol[index] == WHITE_COLOR) color = "W "; else if (playerCol[index] == BLACK_COLOR) color = " B"; stringa = NFormat(" %2d %2s %3d %-20.20s %8d %3s %4d ", j, color, idopp, player[idopp].name, player[idopp].idfide, player[idopp].country, player[idopp].ratingfide); stringa << NFormat("%3s %4d %4.2f %3.1f %4.1f\n", player[idopp].codetitle, (int) arrp[j][0], // diff arrp[j][1], // expected score result, totscore); if ( !(player[i].ratingfide==0 && player[idopp].ratingfide==0) ) {save<0) arofide = arofide/noppfide; save <<" Average rating of rated opponents: "<< roundfloat(arofide);//<<"\n"; save <<" , Performance rating: "<< roundfloat(arofide + p_dp[ roundfloat(100.* totscorefide /noppfide) ] )<<"\n"; if (player[i].ratingfide>0) stringa = NFormat(" We = %5.2f, W-We: %5.2f, Chief Arbiter: %s", totexp, totscorefide - totexp, ARBITER); else if (player[i].ratingfide==0 && totscorefide/noppfide<=0.5) stringa = NFormat (" Rp = %4d, Chief Arbiter: %s", roundfloat (arofide + p_dp[ roundfloat(100.* totscorefide /noppfide) ] ) , ARBITER); else if (player[i].ratingfide==0 && totscorefide/noppfide>0.5) stringa = NFormat(" Rp = %4d, Chief Arbiter: %s", roundfloat ( arofide + 25*(totscorefide-noppfide/2.) ) , ARBITER); save << stringa; save <<"\n ================================================================================================\n"; } } save<<"\n Generated by Vega - www.vegachess.com\n"; save.Close(); } // // find international title norm // void RoundData::FindNorm(void) { int i, arr[N_PLAYER_MAX][4], usedrating[N_ROUND_MAX_RR+1]; String stringa; extern int rat_flor[]; extern int rat_norm[]; if (currentRound<3) return; //at least 3 round FileOut savenorm(PATHDIR + "fidenorm.txt"); savenorm << "\n\n Performance Rating at round " << currentRound << " for norm achievement\n"; savenorm << " (current FIDE limits: GM=2601, IM=2451, WGM=2401, WIM=2251)\n\n"; savenorm<<" ID Name Cat Fed Rtg | GM IM | WGM WIM\n"; savenorm <<" ------------------------------------------------------------------------------\n"; for (i=1; i<=NPlayer; i++) { // he's male arr[i][GM] = arr[i][IM] = arr[i][WGM] = arr[i][WIM] = 0; if (player[i].sex == "m" || player[i].sex == "M") { if (player[i].title < 16) { //he is less than IM arr[i][GM] = CalculatePlayerNorm( i, GM,usedrating); arr[i][IM] = CalculatePlayerNorm( i, IM,usedrating); } else if (player[i].title==16) { //he's IM arr[i][GM] = CalculatePlayerNorm( i, GM,usedrating); } } else { // female if (player[i].title < 14) { //she is less than WIM arr[i][GM] = CalculatePlayerNorm( i, GM,usedrating); arr[i][IM] = CalculatePlayerNorm( i, IM,usedrating); arr[i][WGM] = CalculatePlayerNorm( i, WGM,usedrating); arr[i][WIM] = CalculatePlayerNorm( i, WIM,usedrating); } else if (player[i].title==14) { //she's WIM arr[i][WGM] = CalculatePlayerNorm( i, WGM,usedrating); arr[i][GM] = CalculatePlayerNorm( i, GM,usedrating); arr[i][IM] = CalculatePlayerNorm( i, IM,usedrating); } else if (player[i].title==16) { //she's IM arr[i][GM] = CalculatePlayerNorm( i, GM,usedrating); } else if (player[i].title==18) { //she's wGM arr[i][GM] = CalculatePlayerNorm( i, GM,usedrating); arr[i][IM] = CalculatePlayerNorm( i, WGM,usedrating); } } if (player[i].title < 20) { // not GM savenorm << NFormat(" %3d %-20.20s %3.3s %3.3s %4d | %4d %4d | %4d %4d\n", i, player[i].name, player[i].codetitle, player[i].country, player[i].ratingfide, arr[i][GM], arr[i][IM], arr[i][WGM], arr[i][WIM]); } } savenorm << "\n The following players are performing international norms:\n"; savenorm << " ----------------------------------------------------------\n"; for (i=1; i<=NPlayer; i++) { // he's male if (player[i].sex == "m" || player[i].sex == "M") { if (player[i].title < 16) { //he is less than IM if (arr[i][GM]>=rat_norm[GM] && arr[i][IM] >=rat_norm[IM]) { savenorm << NFormat(" %3d %-20.20s %3.3s %3.3s: GM and IM norms\n", i, player[i].name, player[i].codetitle, player[i].country); } else if (arr[i][GM]>=rat_norm[GM]) { savenorm << NFormat(" %3d %-20.20s %3.3s %3.3s: GM norm\n", i, player[i].name, player[i].codetitle, player[i].country); } else if (arr[i][IM]>=rat_norm[IM]) { savenorm << NFormat(" %3d %-20.20s %3.3s %3.3s: IM norm\n", i, player[i].name, player[i].codetitle, player[i].country); } } else if (player[i].title==16) { //he's IM if (arr[i][GM]>=rat_norm[GM]) { savenorm << NFormat(" %3d %-20.20s %3.3s %3.3s: GM norm\n", i, player[i].name, player[i].codetitle, player[i].country); } } } else { // female if (player[i].title < 14) { //she is less than WIM if (arr[i][WGM]>=rat_norm[WGM] && arr[i][WIM] >=rat_norm[WIM]) { savenorm << NFormat(" %3d %-20.20s %3.3s %3.3s: WGM and WIM norms\n", i, player[i].name, player[i].codetitle, player[i].country); } else if (arr[i][WGM]>=rat_norm[WGM]) { savenorm << NFormat(" %3d %-20.20s %3.3s %3.3s: WGM norm\n", i, player[i].name, player[i].codetitle, player[i].country); } else if (arr[i][WIM]>=rat_norm[WIM]) { savenorm << NFormat(" %3d %-20.20s %3.3s %3.3s: WIM norm\n", i, player[i].name, player[i].codetitle, player[i].country); } } else if (player[i].title==14) { //she's WIM if (arr[i][WGM]>=rat_norm[WGM]) { savenorm << NFormat(" %3d %-20.20s %3.3s %3.3s: WGM norm\n", i, player[i].name, player[i].codetitle, player[i].country); } } } } savenorm <<"\n Generated by Vega - www.vegachess.com\n"; savenorm.Close(); } int RoundData::CalculatePlayerNorm(int i, int typenorm, int arrrating[]) { int j, idopp, nopp, noppfide, index; int id_min[2], rat, rating; float totscore, aro, per; int *roundRes; int *playerOpp; extern int p_dp[]; extern int roundfloat( double per); extern int rat_flor[]; extern int rat_norm[]; if (IS_SWISS) { playerOpp = &playerOpponent[0][0]; roundRes = &roundResult[0][0]; } else { playerOpp = &playerOpponentRR[0][0]; roundRes = &roundResultRR[0][0]; } aro = 0.; nopp = noppfide = 0; totscore = 0.; //score without to consider the forfait // preliminary calculation to calculate nopp (total) and noppfide (only fide opponent) for(j=1; j<=currentRound; j++) { if (IS_SWISS) index = i*(N_ROUND_MAX+1) + j; else index = i*(N_ROUND_MAX_RR+1) + j; idopp = playerOpp[index]; if ( idopp!=0 && (roundRes[index]<3) ) { // not forfait if (player[idopp].ratingfide > 0 ) noppfide++; nopp++; } } // we have to calculate the % of unrated player: if < 33% return 0 // calculate the first lowest rating id_min[0] = 0; rat = 10000; for(j=1; j<=currentRound; j++) { if (IS_SWISS) index = i*(N_ROUND_MAX+1) + j; else index = i*(N_ROUND_MAX_RR+1) + j; idopp = playerOpp[index]; if ( idopp!=0 && (roundRes[index]<3) ) { // not forfait if (player[idopp].ratingfide < rat_flor[typenorm] && player[idopp].ratingfide < rat) { rat = player[idopp].ratingfide; id_min[0] = idopp; } } } // calculate the second lowest rating id_min[1] = 0; rat = 10000; for(j=1; j<=currentRound; j++) { if (IS_SWISS) index = i*(N_ROUND_MAX+1) + j; else index = i*(N_ROUND_MAX_RR+1) + j; idopp = playerOpp[index]; if ( idopp!=0 && (roundRes[index]<3) ) { // not forfait if (player[idopp].ratingfide < rat_flor[typenorm] && player[idopp].ratingfide < rat && idopp!=id_min[0] ) { rat = player[idopp].ratingfide; id_min[1] = idopp; } } } // elaboration if ( ((player[i].ratingfide>0) && (nopp>0)) || ((player[i].ratingfide==0) && (noppfide>=3)) ) { for(j=1; j<=currentRound; j++) { if (IS_SWISS) index = i*(N_ROUND_MAX+1) + j; else index = i*(N_ROUND_MAX_RR+1) + j; idopp = playerOpp[index]; if ( idopp!=0 && (roundRes[index]<3) ) { // not forfait rating = player[idopp].ratingfide; if (rating == 0) rating = 1600; // arise to rating floor if (idopp==id_min[0]) { rating = rat_flor[typenorm]; } else if (idopp==id_min[1]) { rating = rat_flor[typenorm]; } aro += rating; arrrating[j] = rating; if (roundRes[index]==1 || roundRes[index]==3) totscore += 1.0; else if (roundRes[index]==2 || roundRes[index]==6) totscore += 0.5; } } per = aro/nopp + p_dp[ roundfloat(100.*totscore/nopp) ]; if (per<=1000.) per=0.; if (per>4000.) per=9999.; } arrrating[0] = roundfloat(per); // return the performance return roundfloat(per); } void RoundData::calceloFIDE (int idp, double arrp[][2], int round) { int d, k; int idopp; extern double diff[]; for(k=1; k<=round; k++) { //the rating is not calculated for game finished with forfait, code 3, 4, 2, and 6 if (IS_SWISS) { idopp = playerOpponent[idp][k]; if ( idopp>0 && roundResult[idp][k]<3 && player[idopp].ratingfide>0) // no forfeit and rated FIDE opponent { d = abs(player[idp].ratingfide - player[idopp].ratingfide); if ( d > 350) d = 350; arrp[k][0]= (float) d; if (player[idp].ratingfide >= player[idopp].ratingfide) arrp[k][1] = diff[ d ]; else arrp[k][1] = 1.0 - diff[ d ]; } else { arrp[k][0] = 0.; // rating difference arrp[k][1] = 0.; // expected result } } else { idopp = playerOpponentRR[idp][k]; if ( idopp>0 && roundResultRR[idp][k]<3 ) { d = abs(player[idp].ratingfide - player[idopp].ratingfide); if ( d > 350) d = 350; arrp[k][0]= (float) d; if (player[idp].ratingfide >= player[idopp].ratingfide) arrp[k][1] = diff[ d ]; else arrp[k][1] = 1.0 - diff[ d ]; } else { arrp[k][0] = 0.; // rating difference arrp[k][1] = 0.; // expected result } } } } //////////////////////////////// FIDE rating report //////////////////////////////////// FIDERatingReport::FIDERatingReport() { int i, ratedplayers=0; String str; CtrlLayout(*this, ""); edit0 <<= TD.NAMETORNEO; edit1 <<= TD.PLACETORNEO; edit2 <<= TD.HOSTFEDERATION; edit3 <<= TD.DATATORNEO_B; edit4 <<= TD.DATATORNEO_E; // MObjectSetPopupHelp ( _edit000[4], "dd.mm.yyyy", 0, 10000); edit5 <<= AsString(TD.NPlayer); edit5.Disable(); for (i=1; i<=TD.NPlayer; i++) if (player[i].ratingfide>0) ratedplayers++; edit6 <<= AsString(ratedplayers); edit6.Disable(); if (TD.PLAY_SYSTEM==ROUND_ROBIN) str = "Individual: Round Robin"; else if (TD.PLAY_SYSTEM==ROUND_ROBIN2) str = "Individual: Double Round Robin"; else if (TD.PLAY_SYSTEM==USCF) str = "Individual: Swiss-System (USCF)"; else if (TD.PLAY_SYSTEM==DUBOV) str = "Individual: Swiss-System (Dubov)"; else if (TD.PLAY_SYSTEM==LIM) str = "Individual: Swiss-System (Lim)"; else str = "Individual: Swiss-System"; edit7 <<= str; //MObjectSetPopupHelp ( _edit000[7], "specify the pairing system", 0, 10000); edit10 <<= "moves/time, increment"; //MObjectSetPopupHelp ( _edit000[10], "specify the rate of play", 0, 10000); edit8 <<= TD.ARBITER; edit9 <<= ""; btnClose <<= THISBACK(Close); btnDone <<= THISBACK(DoneCB); } void FIDERatingReport::DoneCB() { String stringa, string, color; int *roundRes; int *playerCol; int *playerOpp; int arr[N_PLAYER_MAX+1]; int i, j, id, index; int id_to_pos[N_PLAYER_MAX+1]; extern int CompareScoreName(const void *pid1, const void *pid2); FileOut out( TD.PATHDIR + "fideelo.txt"); for (i=0; iTD.NPlayer) { Exclamation("Enter a valid ID for the Player"); return; } e1 = AsString(~editNorm); if ( e1 == "GM") typenorm = 0; else if ( e1 == "IM") typenorm = 1; else if ( e1 == "WGM") typenorm = 2; else if ( e1 == "WIM") typenorm = 3; placebirth = AsString(~editBirth); rateplay = AsString(~editRateofplay); TD.CalculatePlayerNorm(i, typenorm, usedrating); // get the rating stringa = NFormat("%sfidenormID=%das%s.txt", TD.PATHDIR, i, e1); // FileOut savenorm(PATHDIR + "fidenormID=" + AsString(i) + e1 + ".txt"); FileOut savenorm(stringa); // count titled and rated player for(j=0; j<=5; j++) ctitle[j]=0; for(j=1; j<=TD.currentRound; j++) { if (TD.IS_SWISS) index = i*(N_ROUND_MAX+1) + j; else index = i*(N_ROUND_MAX_RR+1) + j; idopp = playerOpp[index]; if ( player[idopp].country != player[i].country) playernotapplicant++; if ( player[idopp].country != TD.HOSTFEDERATION) playerhostfed++; if ( player[idopp].country != player[i].country) playernothostfed++; if ( player[idopp].ratingfide>0) ratopp++; if ( player[idopp].title>=14 && player[idopp].country != TD.HOSTFEDERATION) titoppnothost++; if (player[idopp].title>=14) titopp++; switch (player[idopp].title) { case 20: ctitle[0]++; break; case 16: ctitle[1]++; break; case 18: ctitle[2]++; break; case 14: ctitle[3]++; break; case 12: ctitle[4]++; break; case 10: ctitle[5]++; break; } // count federations l=0; found=0; while (l<=countcountry && !found) { if ( player[idopp].country == countrylist[l]) { found = 1; break; } else l++; } if (!found) { countcountry++; countrylist[countcountry] = player[idopp].country; } } for(idopp=1; idopp<=TD.NPlayer; idopp++) { if (player[idopp].ratingfide>0 && player[idopp].country != TD.HOSTFEDERATION) totratoppnothost++; if (player[idopp].title>=14 && player[idopp].country != TD.HOSTFEDERATION) tottitoppnothost++; // count federations l=0; found=0; while (l<=totcountcountry && !found) { if ( player[idopp].country != countrylist[l] ) { found = 1; break; } else l++; } if (!found) { totcountcountry++; countrylist[totcountcountry] != player[idopp].country; } } savenorm << " CERTIFICATE OF TITLE RESULT " << e1 << " IT1\n\n"; savenorm << " Name (last name, first name): " << player[i].name << ", Sex: "<