Author Topic: Filtering Unqualified League Points  (Read 1089 times)

Pr Rainier

  • Newbie
  • *
  • Posts: 4
    • View Profile
Filtering Unqualified League Points
« on: March 27, 2019, 08:59:36 AM »
Hi Community,

I run a 20+ player league that holds five regular season games and a League Championship (LC) after the regular season. I'm having an issue automatically eliminating players' unqualified tournament scores.

League Synopsis
Players are awarded points based on their performance during each regular season game (first out - 1 point, second - 2 points, etc.) A players's best four scores are used to determine their league rank. To qualify for the LC, a player must finish in the top 14 of the regular season.

Current Formulas
I am using the following formula to calculate LC Qualified points:
sum(top(numberOfTournaments-1,listpoints))
The following is being used for showing the lowest score to be dropped:
if(numberOfTournaments>buyins,0,bottom(1,listpoints))

The Problem
I have a few players that participated in tournaments prior to joining the league. The scores for these games should not be used to calculate their LC Qualified points. Is there any way to set a variable for the first tournament eligible for calculation and then use that variable to tell TD not use unqualified scores? Or is there a different way (other than manually) of eliminating the first "x" number of scores for specific players?

Thanks for your help,
Rainier

Corey Cooper

  • Administrator
  • Hero Member
  • *****
  • Posts: 6216
    • View Profile
Re: Filtering Unqualified League Points
« Reply #1 on: March 28, 2019, 12:39:04 PM »
This is an interesting issue. Unfortunately there's no concept of when a player joins a league.  The player is simply either part of a league or not.


There's also no consideration given (on a per-player basis) to when a tournament was played.  So you could filter out tournaments prior to a specific date and time, but it will be filtered out for all players.  You can't filter out a tournament [by date] just for some.  You can filter out a tournament by league just for some, but that brings us back to the problem.


One way you could do it I think is to create a separate player for each of your players that played in tournaments before they were part of the league.  For example, my database would have in it player Corey, who is not part of my league.  Corey plays in the first tournament.  Before the second tournament Corey joins the league.  I rename player Corey in the database to "Corey (pre-league)" and create a new player Corey.  Now "Corey (pre-league)" played in the first tournament while the new "Corey" plays in the second and future tournaments.


Not ideal I suppose but would serve to separate statistics.


To implement this for players who participated before they were part of the league:
- Rename the player in the database (and also remove them from the league)
- Create the new player in the database (and add them to the league)
- For each tournament that they participated in AS A LEAGUE MEMBER:
  - Load the tournament
  - On the Players tab, double-click the player to edit
  - Where it says "This player is in your player database." click the "Change" button
  - Select the new player in the database (the one that is a league member)
  - Save the tournament


If you don't care about their stats for tournaments pre-league, you could just delete the "old" player from the database.

Pr Rainier

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Filtering Unqualified League Points
« Reply #2 on: March 28, 2019, 04:22:52 PM »
Thanks for the response, Corey. Unfortunately, many of the players that joined the league after the first tournament have extensive history with the league. By making duplicate copies of them in the database (for pre- and post-entry to the league) I would disassociate their history.

Is there a way to generate a list of string of values for the tournaments played (i.e if three games have been played return [12,8,14]) and then eliminate the first "x" number of values based on when the player joined? I could assign an unused field in the player's database profile (like the zip code) to the first qualified tournament that should be calculated. The resulting formula for LC Qualified Points would look something like:

if (zip>1, sum(last "x" number of tournaments from that string), sum(top(numberOfTournaments-1,listpoints)))

If something like that is possible, can you help me with the formula? I'm not seeing those tokens listed in the cheat sheet.

Thanks again for the help!
Rainier
« Last Edit: March 28, 2019, 04:24:30 PM by Pr Rainier »

Corey Cooper

  • Administrator
  • Hero Member
  • *****
  • Posts: 6216
    • View Profile
Re: Filtering Unqualified League Points
« Reply #3 on: March 29, 2019, 02:08:36 PM »
Unfortunately not. Ultimately you have a filter which filters out certain tournaments and certain players.

When you run stats, you get a set of tournaments, minus any tournaments filtered out by the selected filter.  From those tournaments you get a set of players that participated in them.  The filter can further filter out some of those players.

What you have left is a set of tournaments and a set of players.  The stats for each player are generated from the entire set of tournaments.  There's no way to filter out specific tournaments for specific players.

For variables like "listPoints", for example, you'll get a list (array) of points: [12, 8, 14].  But there's no way to know which of those points is from which tournament.  They are not necessarily in any kind of order.  So, using your example:

if (zip>1, sum(last "x" number of tournaments from that string), sum(top(numberOfTournaments-1,listpoints)))

While you could overload a field to use it as a flag (zip > 1), and you could remove from the list of points one of the values, there's no way to know which one to remove.

Pr Rainier

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Filtering Unqualified League Points
« Reply #4 on: March 30, 2019, 10:45:37 AM »
Thanks Corey!

That's disappointing but understandable. Logically, it would seem that the array was built as the tournaments are imported (as either a stack or queue) based on the order in which they are imported. I don't have that many players to track, so it won't be hard to manually track their scores.

As a final thought, is there anyway to display the array (and the order of values) returned by the "listPoints" variable? In theory, I could reorder the files being called (by changing the file names) and affect the order of the array. I could then determine that logic to figure out which array value(s) should be used to calculate my scores.

Thanks again!
Rainier

Corey Cooper

  • Administrator
  • Hero Member
  • *****
  • Posts: 6216
    • View Profile
Re: Filtering Unqualified League Points
« Reply #5 on: April 01, 2019, 01:17:35 PM »
There's no way to display what listPoints (or any of the other list* variables) consists of, because it's all within the formula context and the output of the formula is a single value.  But you can access a single value of a list variable by using bracket notation:  listPoints[0] for the first item or listPoints[1] for the second, etc.  The formula dialog will complain if you try to access a value beyond the size of the variable.  For example, if listPoints has a value of "12 15 23" (a total of 3 values) and your formula has "listPoints[3]", it will error since index 3 would be the 4th entry.

Theoretically renaming your tournaments could yield the variables in the proper order, but it would be hard to make this generic - it might have to be specific to your tournaments (which is all you care about).  But it seems iffy no matter how you approach it.

While you can access the list variables contents using a single index, getting a range of values out will prove more difficult.  There are no dot notation range operators, like "listPoints(1..5)", which presumably would return a new list of points at indexes 1, 2, 3, 4, and 5.  JS uses .slice and .splice methods, which aren't exposed in TD formulas.