Cup teams chosen from previous season's league tables

Discussions about the internal structures of the game. You can also post here if you'd like to know how things really work (and don't know how to read C code).
Post Reply
MarkC
Posts: 96
Joined: Tue Mar 29, 2005 10:34 pm

Cup teams chosen from previous season's league tables

Post by MarkC »

Cup teams from national leagues are drawn from the previous season's tables, i.e. they don't take promotion and relegation into account. For example, if I get relegated from the English League to the Conference, I still get to play in the League Cup next season.

Now, I know why this is. Obviously we can't roll forward the whole season before drawing cup teams, because we still need to know the winners of last season's cups. So the fix appears at first to be simple: roll the leagues forward, draw cup teams, then delete the old cups.

Unfortunately, as you know :), prom/rel doesn't preserve league order, so cups that rely on teams in certain positions (European cups, and the new Serbian cup!) won't work properly at all. I hate to mention this, because the prom/rel code is quite elegant now. Having to preserve order might make it messy, and might require more accurate definition files (not a good thing).

Maybe there's another solution, but in any case, preserving league order would be a "nice to have"!

Mark
gyboth
Site Admin
Posts: 1421
Joined: Sat Dec 18, 2004 8:42 am
Location: Passau, Germany
Contact:

Re: Cup teams chosen from previous season's league tables

Post by gyboth »

MarkC wrote:Maybe there's another solution, but in any case, preserving league order would be a "nice to have"!
i don't seem to be very bright recently :-P i'm not getting what you mean by 'preserving league order'.

the problem is obviously that european cups rely on the table positions at the end of a season, whereas national cups rely on the table at the beginning of a season.

maybe it'd be best if we just take 'add_week=1' or =2 for national cups which load complete leagues.

gyözö
Press any key to continue or any other key to quit.
MarkC
Posts: 96
Joined: Tue Mar 29, 2005 10:34 pm

Re: Cup teams chosen from previous season's league tables

Post by MarkC »

the problem is obviously that european cups rely on the table positions at the end of a season, whereas national cups rely on the table at the beginning of a season.

maybe it'd be best if we just take 'add_week=1' or =2 for national cups which load complete leagues.
Yes, for cups that load a complete league, this is fine. But what if they load certain positions? Say I have a top league 1 and two parallel leagues 2a and 2b under it, like in the Welsh or the SCG definition. I want the top 8 teams from the two parallel leagues to play a cup.
In real life, this would include teams relegated from 1 to 2a and 2b, since the league tables at the start of a season would have the teams in the same order as they finished last season, with relegated teams at the top and promoted teams at the bottom. This is what I meant by preserving the league order when a new season starts.
At the moment, in bygfoot, there is no way to choose the correct 16 teams. You could pick teams from the league 1 relegation zone, but this wouldn't work in season 1, and would make the definition file totally unintuitive.

(When I started playing 1.9 I actually found it very weird that the teams' positions all went back to alphabetical order at the start of a season, and that relegated teams were dumped at the bottom. But then I read the code and realised that it was the result of elegant, generalised prom/rel functions :))

Right now I don't think there are any cups that can't be fixed by the add_week=1 method, but there might be in future. The Serbian cup works fine as it is, but not the way you'd expect it to. It just happens to load all the teams that lie in the prom/rel zones, so the result is what you expect.
Shall I update my Eng/Wales/Ireland defs to use add_week=1 where necessary? The downside of this is that the cup fixtures won't show up until a week has been played, which is a bit unintuitive for the user.

If we did keep the team order the same then we could load all cups in week zero, provided we did the promotion/relegation first. But would it be too messy...?

Mark
gyboth
Site Admin
Posts: 1421
Joined: Sat Dec 18, 2004 8:42 am
Location: Passau, Germany
Contact:

Re: Cup teams chosen from previous season's league tables

Post by gyboth »

MarkC wrote:But then I read the code and realised that it was the result of elegant, generalised prom/rel functions :))
thanks for the compliment but in fact preserving the order doesn't really have to do with the prom rel system. it's just a matter of appending or prepending to the teams array when team movements are done.
If we did keep the team order the same then we could load all cups in week zero, provided we did the promotion/relegation first. But would it be too messy...?
no, i implemented it. if was fairly simple and little change to the code. now teams are prepended if they got relegated and appended otherwise, so order is preserved (possibly except for the case of a prom_rel element with type PROM_REL_NONE ;-)).

however, this still doesn't solve our dilemma. the league tables are updated at the start of a season AFTER the cups (with add_week 0) have been loaded (to ensure that the right teams participate in the international cups). so having a national cup with add_week 0 will load the teams from tables which don't reflect promotion/relegation at all. we still need to use add_week 1 (or 2, i seem to recall 1 didn't work well when i tried it) for cups that want to have updated tables.

the order problem is solved, however, now the relegated teams are the first ones in the table at the beginning of a new season.

gyözö
Press any key to continue or any other key to quit.
MarkC
Posts: 96
Joined: Tue Mar 29, 2005 10:34 pm

Re: Cup teams chosen from previous season's league tables

Post by MarkC »

no, i implemented it. if was fairly simple and little change to the code.
Oh, excellent :) I'll grab the new cvs tonight and have a look, if I get chance.
however, this still doesn't solve our dilemma. the league tables are updated at the start of a season AFTER the cups (with add_week 0) have been loaded (to ensure that the right teams participate in the international cups).
But the international cups will surely only fetch teams from the top of the first league. Certainly none of them will be getting promoted or relegated! So if the order of all teams in the league is now preserved, I don't see why we can't update the tables before loading week 0 cups.

Mark
gyboth
Site Admin
Posts: 1421
Joined: Sat Dec 18, 2004 8:42 am
Location: Passau, Germany
Contact:

Re: Cup teams chosen from previous season's league tables

Post by gyboth »

MarkC wrote:But the international cups will surely only fetch teams from the top of the first league. Certainly none of them will be getting promoted or relegated! So if the order of all teams in the league is now preserved, I don't see why we can't update the tables before loading week 0 cups.
surely, certainly :-? i'm feeling uneasy. what if you'd like to implement a cup for lower league teams, eg. the second league plus the first 5 of the third league? winchester cup or whatever (isn't there some such cup in england?). that's impossible to do then. totally impossible. whereas we can solve the other problem with the appropriate add_week value.

gyözö

p.s.: moving this topic to 'code discussions'...
Press any key to continue or any other key to quit.
MarkC
Posts: 96
Joined: Tue Mar 29, 2005 10:34 pm

Re: Cup teams chosen from previous season's league tables

Post by MarkC »

OK, I just grabbed the CVS. Yes, relegated teams now appear at the top, but I meant more than that. Teams that are neither promoted nor relegated still all get jumbled up. By "league order" I meant the order of all the teams in the league! (I get the feeling I'm struggling to convey my meaning here :))

what if you'd like to implement a cup for lower league teams, eg. the second league plus the first 5 of the third league? winchester cup or whatever (isn't there some such cup in england?). that's impossible to do then. totally impossible. whereas we can solve the other problem with the appropriate add_week value.
It's not impossible if the teams in the middle of the table don't all get shifted around.

Must admit I haven't heard of the Winchester cup. There is some trophy or other that always seems to be sponsored by a van company, I think that takes (in bygoot terminology) leagues 3 and 4 plus some of league 5. Maybe this was called the Winchester Cup at one time, I've no idea.

Mark
gyboth
Site Admin
Posts: 1421
Joined: Sat Dec 18, 2004 8:42 am
Location: Passau, Germany
Contact:

Re: Cup teams chosen from previous season's league tables

Post by gyboth »

MarkC wrote:Teams that are neither promoted nor relegated still all get jumbled up. By "league order" I meant the order of all the teams in the league! (I get the feeling I'm struggling to convey my meaning here :))
no, i just didn't think of that. i'm going to try and set it right tomorrow.
It's not impossible if the teams in the middle of the table don't all get shifted around.
well, depends on the cup :-P it is impossible if the winchester cup (;-)) says 'take the teams that finish 1st to 5th from the third league'. that won't work because the first few got replaced by relegated teams. and what if we'd want to create a cup with the worst teams from the european leagues, say the last 2 from all countries' first leagues? we'd get the promoted teams from the second leagues.
of course these are silly examples, but they illustrate what we can lose if we execute the team movements before we create the cups.

gyözö
Press any key to continue or any other key to quit.
MarkC
Posts: 96
Joined: Tue Mar 29, 2005 10:34 pm

Re: Cup teams chosen from previous season's league tables

Post by MarkC »

well, depends on the cup :-P it is impossible if the winchester cup (;-)) says 'take the teams that finish 1st to 5th from the third league'. that won't work because the first few got replaced by relegated teams.
Well, that wouldn't work with the current code, for the first season. The Winchester would incorrectly contain five teams from league 3 in season 1, and a mixture of teams from leagues 3 and 2 in other seasons.

Such an unusual definition would be specific to a country, so you could probably take the promotion into account. For example, if two teams are promoted, then choose teams 3-5 of league 3 and the last two teams in league 2.

Such a cup, involving teams promoted to league 2 but no other teams from league 2, would be very unusual so I don't think having to define it this way is particularly bad.
If parallel leagues are involved, you might struggle to pick the right teams, but now we're getting really silly!
and what if we'd want to create a cup with the worst teams from the european leagues, say the last 2 from all countries' first leagues? we'd get the promoted teams from the second leagues.
Yes, this is a better example, since you'd have to use a specific method for each country, depending on how the relegations work, and again, parallel leagues might make it impossible. Still doesn't work in season 1, in any case!
of course these are silly examples, but they illustrate what we can lose if we execute the team movements before we create the cups.
Yes, they are. :wink:

I think we stand to gain more than we lose. Without the change, I still can't see a way to choose only the top 8 teams from each of two parallel leagues (including relegated ones), as per the example in an earlier post. This is a more realistic requirement.

The change would also remove the need for everyone to put add_week = 1 or 2 in cups that draw from a subset of the national leagues, which is the only fix right now for the bug as originally posted.

What about if add_week = -1 meant "choose teams before updating leagues", and add_week = 0 meant "choose teams after updating leagues"? I think add_week = -1 would be required rarely if ever, so it wouldn't really make definition creation any more complex. Most people wouldn't even need to know it existed.
add_week = -1 would have to be treated as 0 in season 1, but as it'd be rare I don't think that the slight inconsistency in season 1 is too much of a worry.

Mark
gyboth
Site Admin
Posts: 1421
Joined: Sat Dec 18, 2004 8:42 am
Location: Passau, Germany
Contact:

Re: Cup teams chosen from previous season's league tables

Post by gyboth »

MarkC wrote:Well, that wouldn't work with the current code, for the first season. The Winchester would incorrectly contain five teams from league 3 in season 1, and a mixture of teams from leagues 3 and 2 in other seasons.
yes, but it would contain exactly the teams that finished on the positions given in the def. of course some of them got promoted.
If parallel leagues are involved, you might struggle to pick the right teams, but now we're getting really silly!
yes. this is obsolete anyway because i am already very enthusiastic about your suggestion below.
Still doesn't work in season 1, in any case!
well, the first season isn't important in my opinion. e.g. the european cup participants are picked at random, as you might have seen (in earlier versions -- as early as 0.5 ;-) -- the strongest teams were picked).
What about if add_week = -1 meant "choose teams before updating leagues", and add_week = 0 meant "choose teams after updating leagues"? I think add_week = -1 would be required rarely if ever, so it wouldn't really make definition creation any more complex. Most people wouldn't even need to know it existed.
add_week = -1 would have to be treated as 0 in season 1, but as it'd be rare I don't think that the slight inconsistency in season 1 is too much of a worry.
an excellent idea. this way we can have both, and i don't think there's a lot of additional code involved.

so let me summarise:
- at the beginning of a season first the cups with add_week=-1 are loaded
- then the promotion/relegation movements are executed, preserving the order of teams
- finally, the cups with add_week=0 get loaded.

seems like the best solution :-)

gyözö
Press any key to continue or any other key to quit.
MarkC
Posts: 96
Joined: Tue Mar 29, 2005 10:34 pm

Re: Cup teams chosen from previous season's league tables

Post by MarkC »

so let me summarise:
- at the beginning of a season first the cups with add_week=-1 are loaded
- then the promotion/relegation movements are executed, preserving the order of teams
- finally, the cups with add_week=0 get loaded.
Yep, sounds perfect. :)

Mark
gyboth
Site Admin
Posts: 1421
Joined: Sat Dec 18, 2004 8:42 am
Location: Passau, Germany
Contact:

Re: Cup teams chosen from previous season's league tables

Post by gyboth »

gyboth wrote:- at the beginning of a season first the cups with add_week=-1 are loaded
- then the promotion/relegation movements are executed, preserving the order of teams
- finally, the cups with add_week=0 get loaded.
implemented, howto and tags ref updated. hope it works like we want it to ;-)

the start_new_season function is a bit longer and uglier now, but i think that was unavoidable :roll:

gyözö
Press any key to continue or any other key to quit.
MarkC
Posts: 96
Joined: Tue Mar 29, 2005 10:34 pm

Re: Cup teams chosen from previous season's league tables

Post by MarkC »

hope it works like we want it to ;-)
Nearly! The "order preservation" looks to be perfect, and the ordinary cups are working as expected. I added a "Winchester Cup" with add_week = -1 and it worked perfectly as well... for two seasons.

Then the game failed at the start of the third season:
** (bygfoot:6565): WARNING **: team_of_id: team with id 200 not found.

I tested without the Winchester cup and still got the error, so I'm not sure what's broken here. I'm afraid I haven't any more time to debug this tonight :(

Mark
gyboth
Site Admin
Posts: 1421
Joined: Sat Dec 18, 2004 8:42 am
Location: Passau, Germany
Contact:

Re: Cup teams chosen from previous season's league tables

Post by gyboth »

MarkC wrote:it worked perfectly as well... for two seasons.
oh :-( i also tested for two seasons. didn't try a third :-P
I tested without the Winchester cup and still got the error, so I'm not sure what's broken here. I'm afraid I haven't any more time to debug this tonight :(
*sigh* let me see if i can find the error...

gyözö
Press any key to continue or any other key to quit.
gyboth
Site Admin
Posts: 1421
Joined: Sat Dec 18, 2004 8:42 am
Location: Passau, Germany
Contact:

Re: Cup teams chosen from previous season's league tables

Post by gyboth »

MarkC wrote:Then the game failed at the start of the third season:
** (bygfoot:6565): WARNING **: team_of_id: team with id 200 not found.

I tested without the Winchester cup and still got the error, so I'm not sure what's broken here. I'm afraid I haven't any more time to debug this tonight :(
i think i got this one. when reordering the cup_reset and fixture_write_cup_fixtures stuff in start_new_season i forgot to reset the cups with add_week > 0. so there were still old fixtures there (but without the corresponding teams in the case of the UEFA supercup).

as a matter of fact the crash already occurred when saving and loading after season 1.

gyözö
Press any key to continue or any other key to quit.
Post Reply