Jump to content

Team competition - how to do it

Recommended Posts

Team competition - how to do it
Please advise. I'm sure there are some good ideas here. I have a rough idea, but it's severely lame. I'm asking for your suggestion on how to solve it and a suggestion for classes. That is, a methodology. I am not asking for the actual implementation.
Problem to be solved: competition of cooperatives. Specifically football. It's in two stages. I want to solve each stage separately. The pictures tell more.


1) The first picture shows what the individual trees will look like in the elimination rounds.
The elimination rounds, where everyone plays everyone
The winners in the round will be dragged into the right tree
2) KO system
All actions are always confirmed only for complete data and only once - the "Apply" button
I will write everything in the DB.


Share this post

Link to post

Something like that. To make it easier for you to comment.


Share this post

Link to post

Maybe the heat is killing me, but I can't follow how some GUI elements (Labels, Checkboxes) go together with booleans, tags and "round type"s. Are you looking for recommendations of how to display this tournament process on screen? Do you want to know how to best store matches in a relational database? I have no idea.


You probably have some written requirements, like a formal document or user stories. This should then enable you to figure out how your data works inside your application.

Share this post

Link to post

Let's just look at the left part: group round
It's a familiar scheme. Nevertheless, I find it very difficult to explain.
I have the basic data written in the application. I have specified:

  • teams in the first "Group round"
  • number of Group round
  • dynamically created graph for KO system

That's all.
In the meantime, I've decided that it will be good if all nodes in the Group round will have CheckBoxes.
At the level of

  • 0 (Group) they have no role
  • 1 check mark means the advancing team

The user's task is to move the advancing team to the adjacent right tree. If this is OK, the user will confirm this. Based on that, I will generate the teams in groups for that round. Here we handle this with the WriteToDB function
It is up to the user whether to have it generated:

  • matches (including rematches)
  • list of players in each match

These two points are not the task of this solution. Nor is entering data for the matches part of this task.
I need to create the conditions to be able to:

  • ReadFromDB: populate individual trees - I don't see a problem here
  • hide unnecessary Group round
  • in the code to accurately identify the individual rounds. So that I can set properties for them. For example: hidden, inaccessible, active. 

I don't need to identify the teams HERE. Then trees are enough for me. At least that's what I think.
Write the result using WriteToDB
I'm not dwelling on the DB structure and working with it right now. That will follow smoothly from the problem itself. It's beyond the scope of this problem.
The challenge is to design for point 7) correctly:

  • data structures
  • classes and their functions/methods

Only the names of the functions, which will explain their operation - are sufficient.

  • Like 1

Share this post

Link to post

I would go data driven ie bottom up *

//who, what, when and where

TeamPlayEvent = record
  Date: Variant
    Scheduled: Boolean;
  Lost: Boolean;

Eachteam = Tlist<TeamPlayEvent>


*Proposed Top down could easily write these future games to said scheme.     



Share this post

Link to post

I don't understand part of the case. It doesn't say "condition". case condition of

That is why I do not understand the whole proposal either.

Share this post

Link to post

Try explaining it so a 5th grader could understand it. 


Managing league playoffs is nothing new. It happens for most sports here in America every year. 


Is what you're doing any different?


For instance, are you looking to sovle a single-elimination tournament, double-elimination tournament, or something more complicated?


Start with that. Forget the implementation for now. (Yes, I know you're trying to build something, but you haven't explained WHAT yet, and are talking about the building blocks already.)

Share this post

Link to post
4 hours ago, David Schwartz said:

Try explaining it so a 5th grader could understand it.

Now it's needed to explain so AI can understand it and not make an EOW. (End of World).🙂


By making the program data driven that is each event of the assets is recorded. We can fish out the UI and/or answers later. Complex flat files and top-down approach not needed for every problem.


I added a variant record to post above which isn't used much so removed it.

unit SoccerDB;

uses   // use only whats needed
  //System.Classes,  Vcl.ExtCtrls, needed for tying into UI
  TGameStatus = (gsLeftScheduled, gsRightScheduled, gsPlaying, gameWon, gameLost, gameIssue);

  TTeam = record
    TLA, Country: String;
    Flag: NativeInt;  //pointer to flag

  PGame = ^TGame;
  TGame = Record
    Team: TTeam;
    Location: string;
    Over: TDateTime;     // rather than messing with variant records
    Status: TGameStatus;
    Key: integer;
    Avator: NativeInt; //pointer to Bitmap of location

  TGames = class(Tlist<PGame>)
    //UIin, UIout: TControls here
    procedure GetTeamsPlayingBetweenTheseTimes(Start, Stop: TDateTime;var theTeams: Tarray<string>);
    procedure SetTeamPlayingatthisTime(Start: TDateTime; ATeam: TTeam);


{ TGames }

procedure TGames.GetTeamsPlayingBetweenTheseTimes(Start, Stop: TDateTime;
  var theTeams: Tarray<string>);

  TheTeams[0] := 'USA';
  TheTeams[1] := 'Brazil';

//first get teams playing in time slice
// then sort by location


procedure TGames.SetTeamPlayingatthisTime(Start: TDateTime; ATeam: TTeam);
// make event records here.


Call it here


{$R *.dfm}
uses SoccerDB;
  Soccer2023: TGames;
procedure TForm6.Button1Click(Sender: TObject);
  aOutPut: TArray<string>;
  s: string;
  Soccer2023:= TGames.Create;
  for s in AOutpUt do







Share this post

Link to post
Posted (edited)

I have found that for me, the best method to use in this case is the small incremental steps method. Per partes. That way the solution to the problem gradually emerges from the depths. Looks like I'm on the right track.
Unfortunately, I can't explain it any better.

I prefer classes for the record. I'm very fond of generics. I don't have to deal with performance.
Thanks to all involved for trying to help me.

Edited by Stano

Share this post

Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now