Domestic cup with 17 entrants

Here you can... report bugs. Open a new thread for each bug, please.
Post Reply
billys_boots
Posts: 105
Joined: Wed Apr 17, 2019 4:45 pm

Domestic cup with 17 entrants

Post by billys_boots »

I have definition where 1 league has 17 teams. This league runs a league cup where all rounds are one off games. The first round should select 2 teams with the other 15 given byes, I believe this is how things works has the default. The problem is that the same 2 teams are always drawn in the first round and the cup stops at the point. The game doesn't crash but this first round game seems to be final. After the game is run there isn't a second round draw and the game just continues. I added another team to the league, to make 18 teams, so that the cup had 4 teams in the first round and this worked OK, same with having 16 teams in the league.

This is the code I created
<cup>
<name>Highland League Cup</name>
<short_name>HL Cup</short_name>
<symbol>flag_scotland.png</symbol>
<sid>scotland_highland</sid>
<last_week>30</last_week>
<week_gap>4</week_gap>
<property>national</property>

<cup_rounds>
<cup_round>
<round_name>1st Round</round_name>
<home_away>0</home_away>
<byes>15</byes>
<choose_teams>
<choose_team>
<choose_team_sid>scotland5b</choose_team_sid>
<randomly>1</randomly>
</choose_team>
</choose_teams>
</cup_round>

<cup_round>
<round_name>2nd Roundl</round_name>
<home_away>0</home_away>
</cup_round>

<cup_round>
<round_name>Quarter Final</round_name>
<home_away>0</home_away>
</cup_round>

<cup_round>
<round_name>Semi Final</round_name>
<home_away>0</home_away>
</cup_round>

<cup_round>
<round_name>Final</round_name>
<neutral>1</neutral>
</cup_round>
</cup_rounds>

</cup>
will_the_canuck
Posts: 141
Joined: Tue Jan 16, 2018 5:54 am
Location: Canada

Re: Domestic cup with 17 entrants

Post by will_the_canuck »

First off billys_boots, I wouldn't call this a bug. I personally think this belongs under the "Definitions" forum topic since it doesn't sound like nothing is breaking when you're running this cup, just that you coded it wrong. So my thoughts are you placed this in the wrong forum topic to begin with.
billys_boots wrote:I have definition where 1 league has 17 teams. This league runs a league cup where all rounds are one off games. The first round should select 2 teams with the other 15 given byes, I believe this is how things works has the default. The problem is that the same 2 teams are always drawn in the first round and the cup stops at the point. The game doesn't crash but this first round game seems to be final. After the game is run there isn't a second round draw and the game just continues. I added another team to the league, to make 18 teams, so that the cup had 4 teams in the first round and this worked OK, same with having 16 teams in the league.
Ok. So the point of this cup is to load 17 teams from a league, in a national cup, and have two of the 17 teams play in the first round in a one-legged match. Then have the winner of that round go to the second round, of which the 15 teams that were given a bye in the first round, would then start their cup run. And the second and subsequent rounds would all be one-legged matches also. Right? But in addition to that, there is not really an order in how the teams are loaded and you are wanting them to be randomized when loaded, so that the teams in the first round aren't necessarily being chosen because of their league standing but because you want it to be random. Is that correct?
This is the code I created
<cup>
<name>Highland League Cup</name>
<short_name>HL Cup</short_name>
<symbol>flag_scotland.png</symbol>
<sid>scotland_highland</sid>
<last_week>30</last_week>
<week_gap>4</week_gap>
<property>national</property>
Ok. So the last week will be week 30. What week does this cup start when you run it in your current scenerio? Is it by chance week 10 that the cup starts? I'm wondering if you're actually hoping that the cup starts in week 14 instead?
<cup_rounds>
<cup_round>
<round_name>1st Round</round_name>
<home_away>0</home_away>
<byes>15</byes>
<choose_teams>
<choose_team>
<choose_team_sid>scotland5b</choose_team_sid>
<randomly>1</randomly>
</choose_team>
</choose_teams>
</cup_round>
The line of

Code: Select all

<randomly>1</<randomly>
is out of place there, as it is mostly used in conjunction with the <generate> tag. If you are trying to randomize the teams so that the first round teams will be random, you can usually leave out that line entirely. The first round cup definition should look like this

Code: Select all

    <cup_round>
        <round_name>1st Round</round_name>
        <home_away>0</home_away>
        <byes>15</byes>
        <choose_teams>
            <choose_team>
                <choose_team_sid>scotland5b</choose_team_sid>
            </choose_team>
        </choose_teams>
    </cup_round>
Subsequently, if that doesn't work like you want, there is the <randomise_teams> tag that can be found in the How-to docs at http://www.bygfoot.com/new/index.php.
<cup_round>
<round_name>2nd Roundl</round_name>
<home_away>0</home_away>
</cup_round>
Don't forget to correct your spelling mistake..."Roundl". :)
<cup_round>
<round_name>Quarter Final</round_name>
<home_away>0</home_away>
</cup_round>

<cup_round>
<round_name>Semi Final</round_name>
<home_away>0</home_away>
</cup_round>

<cup_round>
<round_name>Final</round_name>
<neutral>1</neutral>
</cup_round>
</cup_rounds>

</cup>
My last thought is that you left off the

Code: Select all

<home_away>0</home_away>
line in the last round, or else it might be trying to do two games that last round, both at neutral locations. Anyways, good luck with your definitions.
tstellar
Posts: 52
Joined: Mon Aug 31, 2020 5:46 pm

Re: Domestic cup with 17 entrants

Post by tstellar »

I ran into this same problem and fixed it in my branch: https://github.com/tstellar/bygfoot/com ... a60191aacf
billys_boots
Posts: 105
Joined: Wed Apr 17, 2019 4:45 pm

Re: Domestic cup with 17 entrants

Post by billys_boots »

Thanks for the work in finding a solution to this issue. I'm not a developer so I don't know how to incorporate this fix it to BYGFOOT, so any help would be appreciated. Another cup related change is having an option to decide drawn cup games on penalties but after 90 minutes, instead of 120 minutes as it currently stands. The EFL Cup use this option and have done so for several years.
tstellar
Posts: 52
Joined: Mon Aug 31, 2020 5:46 pm

Re: Domestic cup with 17 entrants

Post by tstellar »

Which operating system/distro are you using?
billys_boots
Posts: 105
Joined: Wed Apr 17, 2019 4:45 pm

Re: Domestic cup with 17 entrants

Post by billys_boots »

I use PCLinuxOS. When I first found Bygfoot I just put in a repo request to the distro admin and they packaged it and did whatever they needed to do so it would install and run
will_the_canuck
Posts: 141
Joined: Tue Jan 16, 2018 5:54 am
Location: Canada

Re: Domestic cup with 17 entrants

Post by will_the_canuck »

tstellar wrote: Mon Oct 12, 2020 11:22 am I ran into this same problem and fixed it in my branch: https://github.com/tstellar/bygfoot/com ... a60191aacf
I want to weigh in on this issue as I wasn't aware that this issue was still an issue to begin with. When you say you "fixed it" in your branch, what problem did you exactly run into and how did you fix it? To be fair to billys_boots though, as this dealt with the Scotland definitions he was working on, I myself never looked at the definitions or played them to test for this issue myself. And whether or not this issue was resolved, I'm not certain but likely assumed it was as no other feedback was given after my post, that I'm aware of.

Initially I felt that the issue was the use of the <randomly> tag here as normally it is used along with the <generate> tag when creating teams for international cups. It is also given an additional tag of <number_of_teams> I believe, which helps to randomize which team(s) from the team sid to choose. That additional tag wasn't used this time. To me, the <randomly> tag just seems out of place. So billys_boots, did removing the <randomly> tag fix the issue or not? I'm just wondering.

Also, as there were 17 teams supposedly in the scotland5b league file and all 17 were loaded in the first round, although 15 were given byes, perhaps also adding <bye>0</bye> in the second round might assist the definitions in working too, since the program may not be fully aware of the other teams? You did say that after the first round, the competition stopped, right? Additionally, after consistent testing, were other teams than the same two teams loaded up into the first round of the competition or after multiple testing, were the same teams still loading up and nothing would change it? Just wondering.

Anyways, those are my thoughts for now and I am curious if this issue was ever resolved as really, I just felt that it was failing because of bad coding in the definition file. Maybe I'll have to try it myself to see.

will_the_canuck
billys_boots
Posts: 105
Joined: Wed Apr 17, 2019 4:45 pm

Re: Domestic cup with 17 entrants

Post by billys_boots »

You are correct Will. I was, still am, working on the Scotland definition. This was put on the back burner for awhile due to the current virus situation and how it effected Scottish football at the end of last season and also this season. One of these was the introduction of a new tier 6 league which was launched but scaled back. The tier 5 league with the 17 team cup problem is yet to start and could possibly lose some clubs, Hopefully things will be back to normal for the start of 2021/22. The Scottish Cup will also be scaled back this season and I have no details on how the new tier 6 will be incorporated into this cup for next season.
tstellar
Posts: 52
Joined: Mon Aug 31, 2020 5:46 pm

Re: Domestic cup with 17 entrants

Post by tstellar »

I think this build will work for you if you want to try: https://github.com/tstellar/bygfoot/act ... /316459974

For this bug, it is a bug in the code and not the definitions. The code was assuming that when a round finished with only 1 winner that the cup was over. It was ignoring the fact that there were still teams in the cup that had byes.
will_the_canuck
Posts: 141
Joined: Tue Jan 16, 2018 5:54 am
Location: Canada

Re: Domestic cup with 17 entrants

Post by will_the_canuck »

tstellar wrote: Tue Oct 20, 2020 12:17 am For this bug, it is a bug in the code and not the definitions. The code was assuming that when a round finished with only 1 winner that the cup was over. It was ignoring the fact that there were still teams in the cup that had byes.
tstellar...Before I begin my reply, I should clarify for everyone that your explanation is not completely clear, to a point. The bug in the code was assuming that when a round finished with only 1 winner, with no more teams being loaded in future rounds, that the cup was over, even if teams who had yet to play were loaded in that round but given byes to play in those future rounds. So if teams were to be loaded in future rounds, the cup would continue. If teams would be loaded in the same round and given byes to play in those future rounds with no other teams being loaded in those same future rounds, then the cup would be over after the round was played with only 1 winner in that round.

I'll admit that I never quite thought of this as potentially being a bug until I tried it myself. When I think of it, this seems like such a rare case but I think I can see other potential instances like this pop up, like if you have 3 teams left in a cup that are already loaded and two of the three teams play in a round and the following round you will have the winner play the third team, but alas, with a bug like this, it likely would stop after those first two teams play. So my question to you tstellar is that after "fixing" this bug with the code, did you try to test it with your fixed version of bygfoot and did it work? Would it play the second round if in the first round, you loaded up 17 teams and gave 15 of them byes, so that in the second round, no other teams would be loaded but for those 17, of which now 16 would be left? That is the question. If your fix works, that is good and we need to have it added to bygfoot for this very issue, although rare as it may seem.

Now onto this particular issue that billys_boots had, I actually came up with a workable solution. As this example from billys_boots is actually from his 2019/2020 definitions for Scotland, although he doesn't have this particular cup activated or it isn't played, I got the relevant files from there and modified them accordingly, calling the country file country_test1.xml. Basically I modified the country file (country_scotland.xml), the relevant cup file (cup_scotland_highland.xml), and the relevant league file (league_scotland5b.xml), and then modified them to fit in with the country name of test1. :)

The relevant cup file (cup_test1_highland.xml) that is working is below:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<cup>
  <name>Highland League Cup</name>
  <short_name>HL Cup</short_name>
  <symbol>flag_scotland.png</symbol>
  <sid>test1_highland</sid>
  <last_week>7</last_week>
  <week_gap>1</week_gap>
  <group>77</group>
  <property>national</property>

  <cup_rounds>
    <!-- Round 1 -->
    <cup_round>
        <round_name>1st Round</round_name>
        <home_away>0</home_away>
	<byes>0</byes>
        <choose_teams>
            <choose_team>
                <choose_team_sid>test1</choose_team_sid>
		<number_of_teams>2</number_of_teams>
		<start_idx>1</start_idx>
		<end_idx>17</end_idx>
		<randomly>1</randomly>
            </choose_team>
        </choose_teams>
    </cup_round>

    <!-- Round 2 -->
    <cup_round>
        <round_name>2nd Round</round_name>
        <home_away>0</home_away>
	<byes>0</byes>
        <choose_teams>
            <choose_team>
                <choose_team_sid>test1</choose_team_sid>
		<number_of_teams>15</number_of_teams>
		<start_idx>1</start_idx>
		<end_idx>17</end_idx>
		<randomly>1</randomly>
            </choose_team>
        </choose_teams>
    </cup_round>
    
    <!-- Round 3 -->
    <cup_round>
        <round_name>Quarter Final</round_name>
        <home_away>0</home_away>
    </cup_round>

    <!-- Round 4 -->
    <cup_round>
        <round_name>Semi Final</round_name>
        <home_away>0</home_away>
    </cup_round>

    <!-- Round 5 -->
    <cup_round>
        <round_name>Final</round_name>
        <home_away>0</home_away>
        <neutral>1</neutral>
    </cup_round>
  </cup_rounds>
</cup>
As I knew how many teams would be loaded into this cup (17 teams), I loaded up 2 teams in the first round and the remaining teams in the second round. This was the only real way that this bug wouldn't affect the cup continuing past the first round. By using the code I did for the first and second rounds, it allowed me to randomly select the teams for both rounds, so that the same teams would not appear in the first round, time after time. This was one of the requirements that billys_boots mentioned. I'd say that normally, the teams might be selected based upon their league standing or such, but in this case, it sounded like the selection would be totally random in general. To make this coding work, I had to assign it to a group which I did in the header part of the cup file. If you want to try the code for yourself, you can download the attached zip file and give it a try.

I'll say that with this issue, it was odd and another bug was exposed from it, so that's a good thing as bugs are bad. :) Although it truly caused frustration, as bugs normally would. But thankfully the bug was understood by someone and hopefully a fix will make its way to the code tree eventually, so that this bug can't bother us again. So thank you tstellar for finding the logic behind this bug and for anyone running into something similar in the future, you can either use my workaround or wait until the bug is fixed in a future update.

Enjoy...

Will aka will_the_canuck
Attachments
scotland-cup-issue-solution.zip
(1.53 KiB) Downloaded 264 times
Post Reply