HELP. TYING TO MAKE SENSE OF A SCHEDULE

Hi im creating a following tournement schedule and the following code is used to generate fizxtures. However i am unsure as to how this happens and what each line actually does. I have commented each line could someone please advise if this is correct and when i try to create the matchups, how does this whole procedure work. For example, when it gets to i=3 and j=2 when 4 teams are participating, then the fixture gets generated 2 vs 5th team which cannot happen. i do not understand how this accompanies it. Thank you ever so much

bye at -1 means team has no bye

publicvoid League()

{

int TotalParticipants= List.size(), NoOfGames = TotalParticipants*(TotalParticipants-1)/2, tmp;

bye = -1;

game =newint[NoOfGames][3];

Team tmpTeam;//tmpteam stores team

for(int i = 1; i < TotalParticipants; i++)

{

for(int j = 0; j < TotalParticipants-i; j++)//for j=1, 0<no of teams-1,I+1..

{

tmp = (i-1)*TotalParticipants-i*(i-1)/2+j;//tmp value

if( (tmp/5 +1) % 2 == 1)

{

tmpTeam = ((Team)List.get(j));//tmpteam = teamlist get team j

tmpTeam.setHomeGames(tmpTeam.getHome()+1);//tmpteam calls homegames method and adds one

game[tmp][0] = tmpTeam.getNum();//gets number of team

tmpTeam = ((Team)List.get(j+i));//tmpteam = teamlist get team j+i

tmpTeam.setAwayGames(tmpTeam.getAway()+1);//tmpteam calls awaygames method and adds one

game[tmp][1] = ((Team)List.get(j+i)).getNum();//gets number of team

}

else

{

tmpTeam = ((Team)List.get(j+i));//tmpteam = teamlist get team j+i

tmpTeam.setHomeGames(tmpTeam.getHome()+1);//tmpteam calls homegames method and adds one

game[tmp][0] = tmpTeam.getNum();//gets number of team

tmpTeam = ((Team)List.get(j));//tmpteam = teamlist get team j

tmpTeam.setAwayGames(tmpTeam.getAway()+1);//tmpteam calls awaygames method and adds one

game[tmp][1] = ((Team)List.get(j)).getNum();//gets number of team

}

game[tmp][2] = -1;//sets bye

}

}

}

>

[3231 byte] By [magiciana] at [2007-11-27 1:35:45]
# 1
any one?
magiciana at 2007-7-12 0:44:25 > top of Java-index,Java Essentials,Java Programming...
# 2
please!
magiciana at 2007-7-12 0:44:25 > top of Java-index,Java Essentials,Java Programming...
# 3

your question is extremely vague and unclear, and shows signs of needing a very involved answer which you probably won't even understand for some time. that's why people aren't answering. rather than repeatedly bump the thread, try and pin down your problem a bit and ask a specific question

georgemca at 2007-7-12 0:44:25 > top of Java-index,Java Essentials,Java Programming...
# 4

> your question is extremely vague and unclear, and

> shows signs of needing a very involved answer which

> you probably won't even understand for some time.

> that's why people aren't answering.

> ...

The annoying capitalized title was my reason not to respond.

prometheuzza at 2007-7-12 0:44:25 > top of Java-index,Java Essentials,Java Programming...
# 5
sorry i had my caps lock on
magiciana at 2007-7-12 0:44:25 > top of Java-index,Java Essentials,Java Programming...
# 6
> sorry i had my caps lock onYes, I noticed.
prometheuzza at 2007-7-12 0:44:25 > top of Java-index,Java Essentials,Java Programming...
# 7
> sorry i had my caps lock onOk, I read your question and, as george said, it is rather vague. Could you try to explain it in more detail? Perhaps explain it with an example of a couple of teams?
prometheuzza at 2007-7-12 0:44:25 > top of Java-index,Java Essentials,Java Programming...
# 8

Ok Thank you mate, Firstly, this generates the games in a league format, who plays who.

With this algorithm, everyone will play each other only once. I have commented each line out to try and make sense

So for example if 3 teams were entered.

totalparticipants would = 3

noofgames= 3

so as i = 1, i<3

j=0 j<2

this now runs creating 2 fixtures

0vs1

1vs2

i increases by 1

i=2 i<3

j=0 j<2

now surely the last 2 fixtues would be created, but this would not make sense as it would generate

4 games and one of these would be wrong

it would get

0vs2

1vs3 .... which is wrong. sorry if its confusing :S

How does this system accompany this.does

it just miss out the value. and for team entrants with 5 in size, there are repeat games. It misses these 2.

and why use these forumulaes. is it some scheduling algorithm. couldnt find info on it anywhere

tmp = (i-1)*TotalParticipants-i*(i-1)/2+j; //tmp value

if( (tmp/5 +1) % 2 == 1)

magiciana at 2007-7-12 0:44:25 > top of Java-index,Java Essentials,Java Programming...
# 9
if possible a basic explanation at each stage. sorry :)and why it does what it does. thank you. u lot are legends
magiciana at 2007-7-12 0:44:25 > top of Java-index,Java Essentials,Java Programming...
# 10

> Ok Thank you mate, Firstly, this generates the games

> in a league format, who plays who.

> With this algorithm, everyone will play each other

> only once. I have commented each line out to try and

> make sense

> So for example if 3 teams were entered.

> totalparticipants would = 3

> noofgames= 3

> ...

Let me get this straight: this is not your code?

Anyway, if you want to let N teams play to eachm other one time, you just need to create a for-statement inside a for-statement like this:

int numTeams = 5;

for(int m = 1; m <= numTeams; m++) {

for(int n = m+1; n <= numTeams; n++) {

System.out.println(m+" vs. "+n);

}

}

prometheuzza at 2007-7-12 0:44:25 > top of Java-index,Java Essentials,Java Programming...
# 11
great thanks. but why is this coding so complex for the same thing, i really need to know what is going on with this aalgorithm please.
magiciana at 2007-7-12 0:44:25 > top of Java-index,Java Essentials,Java Programming...
# 12
> great thanks. but why is this coding so complex for> the same thing, i really need to know what is going> on with this aalgorithm please.I don't know, try asking the author of it.Good luck anyway.
prometheuzza at 2007-7-12 0:44:25 > top of Java-index,Java Essentials,Java Programming...