Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Round Robin formula needed ! Help !!

Author: Matthias Gemuh

Date: 00:32:45 12/27/05

Go up one level in this thread


On December 26, 2005 at 11:07:39, Matthias Gemuh wrote:

>
>nEng = number of engines
>int nTeams[2*nEng], nPairing[nEng][nEng], k, x, y, nNr=0;
>
>    for (int t = 0; t < nEng; t++) {
>        for (int i = 0; i < nEng; i++) {
>            x = nTeams[i]; y = nTeams[i+nEng];
>            if (x == y) continue;
>            if (nPairing[x][y] == 0) nPairing[x][y] = nPairing[y][x] = nNr++;
>        }
>        k = nTeams[0]; for (int j = 0; j < nEng; j++) nTeams[j-1] = nTeams[j];
>nTeams[nEng-1] = k;
>    }
>
>
>I figured out this algo above, but it is not perfect.
>Please, give me the perfect algorithm.
>
>Thanks,
>Matthias.


    int i, j, k, nEng = nEngines, nMid, x, y, nNr = 1, nSide, nPairing[80][80],
nTeams[82], nTeamsCnt[82];
    AnsiString p;
    char pLine[MSG_SIZ];
//
    for (int i = 0; i < nEng; i++) {
        nTeams[i] = i+1; nTeamsCnt[i] = 0;
        for (int j = 0; j < nEng; j++) nPairing[i][j] = 0;
    }
    nTeams[nEng] = 0; nTeamsCnt[nEng] = 0;
    if (nEng & 1) nEng++; nMid = nEng/2;


    for (int h = 0; h < 3*nEng; h++) {
        for (int t = 0; t < nMid; t++) {
            for (int i = 0; i < nMid; i++) {
                x = nTeams[i]; y = nTeams[i+nMid];
                if ((x == 0)||(x == y)||(y == 0)) continue;
                for (int z = 0; z < nEng; z++) {
                    if ((nTeamsCnt[x-1] > nTeamsCnt[z])||(nTeamsCnt[y-1] >
nTeamsCnt[z])) goto weiter;
                }
                if (nPairing[x-1][y-1] == 0) {
                    nPairing[x-1][y-1] = nPairing[y-1][x-1] = nNr++;
                    nTeamsCnt[x-1] += 1; nTeamsCnt[y-1] += 1;
                }
                weiter:;
            }
            k = nTeams[0]; for (int j = 0; j < nMid; j++) nTeams[j-1] =
nTeams[j]; nTeams[nMid-1] = k;
        }
        for (int t = 0; t < 3; t++) {
            k = nTeams[0]; for (int j = 0; j < nEng; j++) nTeams[j-1] =
nTeams[j]; nTeams[nEng-1] = k;
        }
    }




This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.